Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > std::min/max vs own functions

Thread Tools

std::min/max vs own functions

Posts: n/a
On 11.04.2011 18:10, eLVa wrote:
> Hi everyone,
> Below is a test code I made after noticing a big difference in terms
> of running time between the use of std::min or std::max and a
> templated version of it. I'm not sure where it does come from, so any
> comments are welcome.
> The code does not anything usefull, but it is a simplification of the
> real code (the purpose is only to show the difference of timings ..)
> I don't know if there is a proper way of posting a chunk of code, so I
> just drop it here ...
> Then I compiled it with :
> g++ test.cpp -O3 -o test
> And this are the results :
> Took 1.58356
> Took 0.789235
> So the second version which use templated functions is approx 2times
> faster. Is it normal ?
> I tested it on MacosX (10.5) (the timings shown above), and on Linux
> where timings are (5.45 for the first version and 4.71 for the second
> one : the machine is older, thus the big difference, but still the
> second is faster).
> Can anyone reproduce this and tell me if this is normal.
> Thanks

MinGW 4.5.2:
Took 2.4804
Took 2.574

msvc-9.0: (GetTickCount)
Took 3.604
Took 3.01

- RaZ
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using own classloader inside J2EE to load and unload own classes. Stefan Siegl Java 1 07-02-2013 05:05 AM
Allowing access to my own computers within my own network =?Utf-8?B?VHJldm9y?= Wireless Networking 2 07-20-2006 09:05 PM
I have built my own (simple) thread manager [TM], but just found java 5 has its own. Saverio M. Java 0 07-03-2006 08:52 AM
Your own photos in your own book Frank ess Digital Photography 1 12-09-2004 05:54 PM
please help me in distinguish redefining functions, overloading functions and overriding functions. Xiangliang Meng C++ 1 06-21-2004 03:11 AM