0

I have two functions that carry out the same functionality But has been implemented in different ways. I wanted to use the efficient one from the two.

I could write the Timestamp before entering and after exiting the functions in a file. But I wanted to know if there is a better way to figure out the above.

I saw profilers like VerySleepy, Visual Studios 2008 C++ Profiler But the information they generated was which function is called when. (perhaps i have gone wrong in using them). Also wanted to know if there is something existing for Visual C++ like Valgrind on Linux.

octopusgrabbus
  • 10,555
  • 15
  • 68
  • 131
Nathan
  • 674
  • 8
  • 22
  • I normally just use the QueryPerformanceCounter() to time the call - see http://stackoverflow.com/questions/4727006/c-logging-and-performance-tuning-library – Martin Beckett Apr 23 '12 at 17:15

1 Answers1

1

If you really only want to compare these two then do the Timestamp thing but call each function say 1 million times each and compare the aggregate timings.

start timer
for i = 1 to 1m, call function
stop timer

This approach assumes that the functions execution time is not dependent on the number of times it is called, i.e. the first time to call it takes about as long as any subsequent call.

If you need more detailed profiling info there are plenty of options.

Community
  • 1
  • 1
Steve Townsend
  • 53,498
  • 9
  • 91
  • 140