我正在使用 Qt 4.8,并尝试跨平台(至少在 linux 和 mac 上)。
我需要在图形用户界面中可视化操作需要多少时间。我试过:
QTime t;
t.start();
functionCall();
qDebug() << t.elapsed() << "ms";
但我读到它不可靠。一些替代方案?
抱歉,没有 C++0x
最佳答案
这不可靠,也不是很准确。使用 QElapsedTimer反而。
当然,QTime 和 QElapsedTimer 都测量挂钟时间。您需要 QtTest 和 QBENCHMARK in order to get other measures (callgrind、CPU 滴答计数器等),另请参阅 QTest::setBenchmarkResult功能。
关于c++ - 在 Qt 中测试一个操作花费多少时间的最简单方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17898938/