获取执行代码段的时间 [英] Get time of execution piece of code
本文介绍了获取执行代码段的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Qt / C ++中花费毫秒的时间执行一段代码?
How do I get milliseconds time of execution of a piece of code in Qt/C++?
推荐答案
c $ c> QTime 类。使用 .start()
(或 .restart()
)启动它,然后检查传递的毫秒数 .elapsed()
。当然,精度最终取决于底层的操作系统,尽管在主要的平台上你应该毫无困难地得到真正的毫秒分辨率。
Use the QTime
class. Start it with .start()
(or .restart()
) and then check the amount of milliseconds passed with .elapsed()
. Naturally, the precision ultimately depends on the underlying OS, although with the major platforms you should have no trouble getting a real millisecond resolution.
这篇关于获取执行代码段的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文