Windows上的C ++ Profiler [英] C++ Profiler on Windows

查看:91
本文介绍了Windows上的C ++ Profiler的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用C ++,有时我不知道我的编译器会喜欢两种不同的算法实现方式.我可以使用一个简单工具来查看我的代码执行多少时间吗?

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?

我正在使用gcc编译器

Im using gcc compiler

推荐答案

如果您想确定整个程序运行了多长时间,则应使用Code-Blocks/Visual Studio告诉您程序何时关闭.它应该在底部的日志中.

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.

如果您想确定一条特定的线或功能需要花费多长时间,我建议您进行研究 clock() QueryPerformanceFrequency()以及如何使用它们.

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.

clock()函数很慢,但使用起来更容易.一个例子:

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;

这篇关于Windows上的C ++ Profiler的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆