除了在断点处停止时,如何测量一大段代码的时间? [英] How can one measure time for a large block of code except when stopped at a breakpoint?

查看:98
本文介绍了除了在断点处停止时,如何测量一大段代码的时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Windows上开发C ++游戏/模拟/图形应用程序.
(编辑开始)如果重要,我正在使用Visual Studio2013.(编辑结束)

I am working on a C++ game / simulation / graphics application on Windows.
(edit start) If it matters, I am using Visual Studio 2013. (edit end)

设置:我正在使用QueryPerformanceCounter()测量从一帧到下一帧的时间.

Setup: I am measuring the time from one frame to the next using QueryPerformanceCounter().

复制步骤: 在断点处停下来进行一些调试.

Steps to Reproduce: Stop at a breakpoint for some debugging.

当前不良结果::应用程序恢复执行时,下次调用QueryPerformanceCounter()时,它将返回一个时间值,其中包括在调试器上暂停所花费的所有时间.这导致帧时间长度异常大.

Current Undesired Result: When application resumes execution, the next time QueryPerformanceCounter() is called, it will return a time value that includes all of the time was spent paused at the debugger. This results in a frame time length that is abnormally large.

所需结果: QueryPerformanceCounter()将返回一个时间值,该值不包括我在断点处暂停调试所花费的时间.

Desired Result: QueryPerformanceCounter() will return a time value that does not include however much time I spent paused at a breakpoint for debugging.

我怎样才能达到预期的效果?
1.我应该使用其他功能代替QueryPerformanceCounter吗?
2. IDE(例如Visual Studio)中是否可以更改某些设置?
3.是否有使用QueryPerformanceCounter或其他方法的特殊方法 时间函数?
4.等等.

How can I achieve the desired result?
1. Is there a different function that I should use instead of QueryPerformanceCounter?
2. Is there some setting in an IDE (i.e. Visual Studio) that can be changed?
3. Is there some special way to use QueryPerformanceCounter or other time function?
4. etc.

参考注释:这里列出了一个类似的问题,但是对我来说确定解决方案没有帮助. 跟踪在调试器中花费的时间

Reference Notes: There is a somewhat similar question listed here, but it was not helpful for me to identify a solution. Tracking Time Spent in Debugger

推荐答案

使用商业分析工具.测量执行一个函数或方法所花费的时间正是它们的目的.

Use a commercial profiling tool. Measuring how long it took to execute a function or method is exactly what they are made for.

此外,为什么还要担心调试时花了多长时间?您是否打算以调试模式发布给客户,并在客户玩游戏时逐行远程爬网?如果要检查帧时间,请在启用优化功能的情况下对其进行检查.

Also, why would you care how long something took while you were debugging? Are you planning on releasing to your customers in debug mode, and crawling through line by line remotely while they play? If you want to examine frame time, examine it in release with optimizations turned on.

这篇关于除了在断点处停止时,如何测量一大段代码的时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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