简体   繁体   中英

How to measure execution time in ns, ps or clk cycles in visual c++?

有没有一种方法可以衡量在Visual C ++中我的C ++代码的特定部分花费了多少时间?

Do you need it for debug only or do you need it for the application you are making? I can tell you a technique for debug only:

  • Put breakpoint in the starting code line and another in final one.
  • When the execution stops at the first breakpoint, in the Watch Window watch for the $clk variable.
  • It almost certainly has a value different of Zero. Define it to Zero.
  • Then wait for the execution to flow to the second breakpoint. Now look to the Watch Window and the $clk variable has the time elapsed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM