Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ Profiler on Windows [duplicate]

I'm at the beginning with C++ and sometimes I don't know how much my compiler will like two different implementation of an alghoritm. Is there a simple tool I can use to see how much time takes my code to execute?

EDIT: Im using gcc compiler

like image 377
doplumi Avatar asked Dec 20 '22 09:12

doplumi


2 Answers

Free

  • Very Sleepy
  • Proffy

Not Free

  • AMD
  • Intel VTune
  • Semantic Designs
like image 80
Caesar Avatar answered Dec 24 '22 01:12

Caesar


If you want to mesure how long the entire program run's, then Code-Blocks/Visual studio should tell you when the program closes. It should be in the log at the bottom.

If you want to mesure how long a specific line, or function takes, I would suggjest researching clock() or QueryPerformanceFrequency() and how to use them.

the clock() function is slow, but it's easyer to use. an example:

float start_time = clock()/CLOCKS_PER_SEC;
func();
float end_time = clock()/CLOCKS_PER_SEC;
float dtime = start_time - end_time;
like image 30
Wolfgang Skyler Avatar answered Dec 24 '22 00:12

Wolfgang Skyler