本文介绍了获取在Qt的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Qt中寻找等效的 GetTickCount()
I'm looking for the equivalent in Qt to GetTickCount()
测量一段代码运行所花费的时间:
Something that will allow me to measure the time it takes for a segment of code to run as in:
uint start = GetTickCount();
// do something..
uint timeItTook = GetTickCount() - start;
有什么建议吗?
推荐答案
QTime
?根据您的平台,它应该有1毫秒的精度。代码看起来像这样:
How about QTime
? Depending on your platform it should have 1 millisecond accuracy. Code would look something like this:
QTime myTimer;
myTimer.start();
// do something..
int nMilliseconds = myTimer.elapsed();
这篇关于获取在Qt的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!