C++ Profiler on Windows [duplicate]

二次信任 提交于 2019-12-03 13:55:10

问题


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


回答1:


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;



回答2:


Free

  • Very Sleepy
  • Proffy

Not Free

  • AMD
  • Intel VTune
  • Semantic Designs



回答3:


I have had very good experience with AQtime from Smart Bear, it is not free, but you can get a free trial. It integrates really well into Visual C++ and RAD Studio from Embarcardero.

http://smartbear.com/products/qa-tools/application-performance-profiling

The data is easily accessible in the IDE, and especially the hit count and time spent numbers in the gutter section, next to the line numbers is useful.



来源:https://stackoverflow.com/questions/15167544/c-profiler-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!