一、 QElapsedTimer方法
- API原型
void QElapsedTimer::start()
qint64 QElapsedTimer::elapsed() const
- 使用
#include <QElapsedTimer>
#include <QDebug>
void xxxxxx:test()
{
QElapsedTimer timer;
timer.start();
// 代码实现
qDebug() << u8"耗时为: " << timer.elapsed() << u8" 毫秒";
}
二、 QTime 方法
- API原型
void QTime::start()
int QTime::elapsed() const
- 使用
#include <QTime>
#include <QDebug>
void xxxxxx::test()
{
QTime timer;
timer.start();
// 代码实现
qDebug() << u8"耗时为: " << timer.elapsed() << u8" 毫秒";
}