Convert uses of QTime as a timer to QElapsedTimer
Change-Id: I2297f61efa5adf9ea5194c7f3ff68574cbcf452c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
parent
feb06decfe
commit
84e89c1e9e
@ -132,7 +132,7 @@ void DownloadManager::startNextDownload()
|
||||
|
||||
// prepare the output
|
||||
printf("Downloading %s...\n", url.toEncoded().constData());
|
||||
downloadTime.start();
|
||||
downloadTimer.start();
|
||||
}
|
||||
|
||||
void DownloadManager::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
|
||||
@ -140,7 +140,7 @@ void DownloadManager::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
|
||||
progressBar.setStatus(bytesReceived, bytesTotal);
|
||||
|
||||
// calculate the download speed
|
||||
double speed = bytesReceived * 1000.0 / downloadTime.elapsed();
|
||||
double speed = bytesReceived * 1000.0 / downloadTimer.elapsed();
|
||||
QString unit;
|
||||
if (speed < 1024) {
|
||||
unit = "bytes/sec";
|
||||
|
@ -83,7 +83,7 @@ private:
|
||||
QQueue<QUrl> downloadQueue;
|
||||
QNetworkReply *currentDownload = nullptr;
|
||||
QFile output;
|
||||
QTime downloadTime;
|
||||
QElapsedTimer downloadTimer;
|
||||
TextProgressBar progressBar;
|
||||
|
||||
int downloadedCount = 0;
|
||||
|
@ -96,8 +96,8 @@ void RateController::transfer()
|
||||
if (sockets.isEmpty())
|
||||
return;
|
||||
|
||||
int msecs = 1000;
|
||||
if (!stopWatch.isNull())
|
||||
qint64 msecs = 1000;
|
||||
if (stopWatch.isValid())
|
||||
msecs = qMin(msecs, stopWatch.elapsed());
|
||||
|
||||
qint64 bytesToWrite = (upLimit * msecs) / 1000;
|
||||
|
@ -53,7 +53,7 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QSet>
|
||||
#include <QTime>
|
||||
#include <QElapsedTimer>
|
||||
|
||||
class PeerWireClient;
|
||||
|
||||
@ -79,7 +79,7 @@ public slots:
|
||||
void scheduleTransfer();
|
||||
|
||||
private:
|
||||
QTime stopWatch;
|
||||
QElapsedTimer stopWatch;
|
||||
QSet<PeerWireClient *> sockets;
|
||||
int upLimit;
|
||||
int downLimit;
|
||||
|
@ -56,7 +56,7 @@
|
||||
#include <QOpenGLBuffer>
|
||||
#include <QVector3D>
|
||||
#include <QMatrix4x4>
|
||||
#include <QTime>
|
||||
#include <QElapsedTimer>
|
||||
#include <QVector>
|
||||
#include <QPushButton>
|
||||
|
||||
@ -106,7 +106,7 @@ private:
|
||||
bool m_qtLogo;
|
||||
QList<Bubble *> m_bubbles;
|
||||
int m_frames;
|
||||
QTime m_time;
|
||||
QElapsedTimer m_time;
|
||||
QOpenGLShader *m_vshader1;
|
||||
QOpenGLShader *m_fshader1;
|
||||
QOpenGLShader *m_vshader2;
|
||||
|
@ -54,7 +54,7 @@
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QDir>
|
||||
#include <QTime>
|
||||
#include <QElapsedTimer>
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
|
||||
@ -146,19 +146,19 @@ int main(int argc, char** argv)
|
||||
|
||||
int singleThreadTime = 0;
|
||||
{
|
||||
QTime time;
|
||||
time.start();
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
WordCount total = singleThreadedWordCount(files);
|
||||
singleThreadTime = time.elapsed();
|
||||
singleThreadTime = timer.elapsed();
|
||||
qDebug() << "single thread" << singleThreadTime;
|
||||
}
|
||||
|
||||
int mapReduceTime = 0;
|
||||
{
|
||||
QTime time;
|
||||
time.start();
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
WordCount total = mappedReduced(files, countWords, reduce);
|
||||
mapReduceTime = time.elapsed();
|
||||
mapReduceTime = timer.elapsed();
|
||||
qDebug() << "MapReduce" << mapReduceTime;
|
||||
}
|
||||
qDebug() << "MapReduce speedup x" << ((double)singleThreadTime - (double)mapReduceTime) / (double)mapReduceTime + 1;
|
||||
|
@ -533,8 +533,6 @@ Scene::Scene(int width, int height, int maxTextureSize)
|
||||
m_timer->setInterval(20);
|
||||
connect(m_timer, &QTimer::timeout, this, [this](){ update(); });
|
||||
m_timer->start();
|
||||
|
||||
m_time.start();
|
||||
}
|
||||
|
||||
Scene::~Scene()
|
||||
|
@ -220,7 +220,7 @@ private:
|
||||
void initGL();
|
||||
QPointF pixelPosToViewPos(const QPointF& p);
|
||||
|
||||
QTime m_time;
|
||||
QTime m_time; // ### Qt 6: remove (unused)
|
||||
int m_lastTime;
|
||||
int m_mouseEventTime;
|
||||
int m_distExp;
|
||||
|
@ -54,7 +54,7 @@
|
||||
#include "arthurwidgets.h"
|
||||
|
||||
#include <QBasicTimer>
|
||||
#include <QDateTime>
|
||||
#include <QElapsedTimer>
|
||||
#include <QPainterPath>
|
||||
|
||||
class PathDeformRenderer : public ArthurFrame
|
||||
@ -103,7 +103,7 @@ private:
|
||||
QBasicTimer m_repaintTimer;
|
||||
// QBasicTimer m_fpsTimer;
|
||||
// int m_fpsCounter;
|
||||
QTime m_repaintTracker;
|
||||
QElapsedTimer m_repaintTracker;
|
||||
|
||||
QVector<QPainterPath> m_paths;
|
||||
QVector<QPointF> m_advances;
|
||||
|
@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE
|
||||
\snippet qelapsedtimer/main.cpp 0
|
||||
|
||||
In this example, the timer is started by a call to start() and the
|
||||
elapsed timer is calculated by the elapsed() function.
|
||||
elapsed time is calculated by the elapsed() function.
|
||||
|
||||
The time elapsed can also be used to recalculate the time available for
|
||||
another operation, after the first one is complete. This is useful when
|
||||
|
@ -180,7 +180,7 @@
|
||||
#include "qimagereader.h"
|
||||
#include "qpixmap.h"
|
||||
#include "qrect.h"
|
||||
#include "qdatetime.h"
|
||||
#include "qelapsedtimer.h"
|
||||
#include "qtimer.h"
|
||||
#include "qpair.h"
|
||||
#include "qmap.h"
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <qtconcurrentthreadengine.h>
|
||||
#include <qexception.h>
|
||||
#include <QThread>
|
||||
#include <QElapsedTimer>
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
using namespace QtConcurrent;
|
||||
@ -382,7 +383,7 @@ void tst_QtConcurrentThreadEngine::cancelQueuedSlowUser()
|
||||
{
|
||||
const int times = 100;
|
||||
|
||||
QTime t;
|
||||
QElapsedTimer t;
|
||||
t.start();
|
||||
|
||||
{
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QtCore/QProcess>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QElapsedTimer>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QThread>
|
||||
#include <QtCore/QTemporaryDir>
|
||||
@ -420,7 +421,7 @@ void tst_QProcess::echoTest()
|
||||
|
||||
process.write(input);
|
||||
|
||||
QTime stopWatch;
|
||||
QElapsedTimer stopWatch;
|
||||
stopWatch.start();
|
||||
do {
|
||||
QVERIFY(process.isOpen());
|
||||
@ -479,7 +480,7 @@ void tst_QProcess::echoTest2()
|
||||
QVERIFY(spy1.isValid());
|
||||
QVERIFY(spy2.isValid());
|
||||
|
||||
QTime stopWatch;
|
||||
QElapsedTimer stopWatch;
|
||||
stopWatch.start();
|
||||
forever {
|
||||
QTestEventLoop::instance().enterLoop(1);
|
||||
@ -2072,7 +2073,7 @@ void tst_QProcess::fileWriterProcess()
|
||||
stdinStr += line;
|
||||
}
|
||||
|
||||
QTime stopWatch;
|
||||
QElapsedTimer stopWatch;
|
||||
stopWatch.start();
|
||||
const QString fileName = m_temporaryDir.path() + QLatin1String("/fileWriterProcess.txt");
|
||||
const QString binary = QDir::currentPath() + QLatin1String("/fileWriterProcess/fileWriterProcess");
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include <QSharedMemory>
|
||||
#include <QTest>
|
||||
#include <QThread>
|
||||
#include <QElapsedTimer>
|
||||
|
||||
#define EXISTING_SHARE "existing"
|
||||
#define EXISTING_SIZE 1024
|
||||
@ -645,7 +646,7 @@ public:
|
||||
|
||||
char *memory = (char*)producer.data();
|
||||
memory[1] = '0';
|
||||
QTime timer;
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
int i = 0;
|
||||
while (i < 5 && timer.elapsed() < 5000) {
|
||||
|
@ -38,6 +38,7 @@
|
||||
|
||||
#include <qtimer.h>
|
||||
#include <qthread.h>
|
||||
#include <qelapsedtimer.h>
|
||||
|
||||
#if defined Q_OS_UNIX
|
||||
#include <unistd.h>
|
||||
@ -526,7 +527,7 @@ public:
|
||||
QBasicTimer m_timer;
|
||||
|
||||
int m_interval;
|
||||
QTime m_startedTime;
|
||||
QElapsedTimer m_elapsedTimer;
|
||||
QEventLoop eventLoop;
|
||||
|
||||
inline RestartedTimerFiresTooSoonObject()
|
||||
@ -538,7 +539,7 @@ public:
|
||||
static int interval = 1000;
|
||||
|
||||
m_interval = interval;
|
||||
m_startedTime.start();
|
||||
m_elapsedTimer.start();
|
||||
m_timer.start(interval, this);
|
||||
|
||||
// alternate between single-shot and 1 sec
|
||||
@ -552,7 +553,7 @@ public:
|
||||
|
||||
m_timer.stop();
|
||||
|
||||
int elapsed = m_startedTime.elapsed();
|
||||
int elapsed = m_elapsedTimer.elapsed();
|
||||
|
||||
if (elapsed < m_interval / 2) {
|
||||
// severely too early!
|
||||
@ -590,10 +591,10 @@ public:
|
||||
public slots:
|
||||
void longLastingSlot()
|
||||
{
|
||||
// Don't use timers for this, because we are testing them.
|
||||
QTime time;
|
||||
time.start();
|
||||
while (time.elapsed() < 200) {
|
||||
// Don't use QTimer for this, because we are testing it.
|
||||
QElapsedTimer control;
|
||||
control.start();
|
||||
while (control.elapsed() < 200) {
|
||||
for (int c = 0; c < 100000; c++) {} // Mindless looping.
|
||||
}
|
||||
if (++count >= 2) {
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <QBuffer>
|
||||
#include <QByteArray>
|
||||
#include <QDebug>
|
||||
#include <QElapsedTimer>
|
||||
#include <QFile>
|
||||
#include <QTcpSocket>
|
||||
#include <QTemporaryDir>
|
||||
@ -996,7 +997,7 @@ struct CompareIndicesForArray
|
||||
void tst_QTextStream::performance()
|
||||
{
|
||||
// Phase #1 - test speed of reading a huge text file with QFile.
|
||||
QTime stopWatch;
|
||||
QElapsedTimer stopWatch;
|
||||
|
||||
const int N = 3;
|
||||
const char * readMethods[N] = {
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
#include <QAtomicInt>
|
||||
#include <QCoreApplication>
|
||||
#include <QElapsedTimer>
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
@ -851,7 +852,7 @@ void tst_QAtomicInt::operators()
|
||||
|
||||
void tst_QAtomicInt::testAndSet_loop()
|
||||
{
|
||||
QTime stopWatch;
|
||||
QElapsedTimer stopWatch;
|
||||
stopWatch.start();
|
||||
|
||||
int iterations = 10000000;
|
||||
|
@ -27,6 +27,7 @@
|
||||
****************************************************************************/
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QElapsedTimer>
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
#include <QtConcurrent>
|
||||
@ -878,7 +879,7 @@ void tst_QFutureWatcher::incrementalFilterResults()
|
||||
void tst_QFutureWatcher::qfutureSynchronizer()
|
||||
{
|
||||
int taskCount = 1000;
|
||||
QTime t;
|
||||
QElapsedTimer t;
|
||||
t.start();
|
||||
|
||||
{
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <qcoreapplication.h>
|
||||
#include <qreadwritelock.h>
|
||||
#include <qelapsedtimer.h>
|
||||
#include <qmutex.h>
|
||||
#include <qthread.h>
|
||||
#include <qwaitcondition.h>
|
||||
@ -237,7 +238,7 @@ void tst_QReadWriteLock::tryReadLock()
|
||||
testsTurn.release();
|
||||
|
||||
threadsTurn.acquire();
|
||||
QTime timer;
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
QVERIFY(!readWriteLock.tryLockForRead(1000));
|
||||
QVERIFY(timer.elapsed() >= 1000);
|
||||
@ -500,7 +501,7 @@ public:
|
||||
int holdTime;
|
||||
int waitTime;
|
||||
bool print;
|
||||
QTime t;
|
||||
QElapsedTimer t;
|
||||
inline ReadLockLoopThread(QReadWriteLock &l, int runTime, int holdTime=0, int waitTime=0, bool print=false)
|
||||
:testRwlock(l)
|
||||
,runTime(runTime)
|
||||
@ -536,7 +537,7 @@ public:
|
||||
int holdTime;
|
||||
int waitTime;
|
||||
bool print;
|
||||
QTime t;
|
||||
QElapsedTimer t;
|
||||
inline WriteLockLoopThread(QReadWriteLock &l, int runTime, int holdTime=0, int waitTime=0, bool print=false)
|
||||
:testRwlock(l)
|
||||
,runTime(runTime)
|
||||
@ -574,7 +575,7 @@ public:
|
||||
int runTime;
|
||||
int waitTime;
|
||||
int maxval;
|
||||
QTime t;
|
||||
QElapsedTimer t;
|
||||
inline WriteLockCountThread(QReadWriteLock &l, int runTime, int waitTime, int maxval)
|
||||
:testRwlock(l)
|
||||
,runTime(runTime)
|
||||
@ -615,7 +616,7 @@ public:
|
||||
QReadWriteLock &testRwlock;
|
||||
int runTime;
|
||||
int waitTime;
|
||||
QTime t;
|
||||
QElapsedTimer t;
|
||||
inline ReadLockCountThread(QReadWriteLock &l, int runTime, int waitTime)
|
||||
:testRwlock(l)
|
||||
,runTime(runTime)
|
||||
@ -873,7 +874,7 @@ void tst_QReadWriteLock::deleteOnUnlock()
|
||||
|
||||
DeleteOnUnlockThread thread2(&lock, &startup, &waitMutex);
|
||||
|
||||
QTime t;
|
||||
QElapsedTimer t;
|
||||
t.start();
|
||||
while(t.elapsed() < 4000) {
|
||||
lock = new QReadWriteLock();
|
||||
@ -899,7 +900,7 @@ void tst_QReadWriteLock::uncontendedLocks()
|
||||
uint count=0;
|
||||
int millisecs=1000;
|
||||
{
|
||||
QTime t;
|
||||
QElapsedTimer t;
|
||||
t.start();
|
||||
while(t.elapsed() <millisecs)
|
||||
{
|
||||
@ -908,7 +909,7 @@ void tst_QReadWriteLock::uncontendedLocks()
|
||||
}
|
||||
{
|
||||
QReadWriteLock rwlock;
|
||||
QTime t;
|
||||
QElapsedTimer t;
|
||||
t.start();
|
||||
while(t.elapsed() <millisecs)
|
||||
{
|
||||
@ -919,7 +920,7 @@ void tst_QReadWriteLock::uncontendedLocks()
|
||||
}
|
||||
{
|
||||
QReadWriteLock rwlock;
|
||||
QTime t;
|
||||
QElapsedTimer t;
|
||||
t.start();
|
||||
while(t.elapsed() <millisecs)
|
||||
{
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
#include <qcoreapplication.h>
|
||||
#include <qdatetime.h>
|
||||
#include <qelapsedtimer.h>
|
||||
#include <qmutex.h>
|
||||
#include <qthread.h>
|
||||
#include <qtimer.h>
|
||||
@ -244,8 +244,8 @@ public:
|
||||
QMutexLocker locker(&mutex);
|
||||
|
||||
elapsed = 0;
|
||||
QTime time;
|
||||
time.start();
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
switch (sleepType) {
|
||||
case Second:
|
||||
sleep(interval);
|
||||
@ -257,7 +257,7 @@ public:
|
||||
usleep(interval);
|
||||
break;
|
||||
}
|
||||
elapsed = time.elapsed();
|
||||
elapsed = timer.elapsed();
|
||||
|
||||
cond.wakeOne();
|
||||
}
|
||||
@ -601,8 +601,7 @@ void tst_QThread::msleep()
|
||||
thread.interval = 120;
|
||||
thread.start();
|
||||
QVERIFY(thread.wait(five_minutes));
|
||||
#if defined (Q_OS_WIN)
|
||||
// Since the resolution of QTime is so coarse...
|
||||
#if defined (Q_OS_WIN) // May no longer be needed
|
||||
QVERIFY(thread.elapsed >= 100);
|
||||
#else
|
||||
QVERIFY(thread.elapsed >= 120);
|
||||
@ -616,8 +615,7 @@ void tst_QThread::usleep()
|
||||
thread.interval = 120000;
|
||||
thread.start();
|
||||
QVERIFY(thread.wait(five_minutes));
|
||||
#if defined (Q_OS_WIN)
|
||||
// Since the resolution of QTime is so coarse...
|
||||
#if defined (Q_OS_WIN) // May no longer be needed
|
||||
QVERIFY(thread.elapsed >= 100);
|
||||
#else
|
||||
QVERIFY(thread.elapsed >= 120);
|
||||
@ -948,9 +946,9 @@ void tst_QThread::stressTest()
|
||||
if (EmulationDetector::isRunningArmOnX86())
|
||||
QSKIP("Qemu uses too much memory for each thread. Test would run out of memory.");
|
||||
|
||||
QTime t;
|
||||
t.start();
|
||||
while (t.elapsed() < one_minute) {
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
while (timer.elapsed() < one_minute) {
|
||||
Current_Thread t;
|
||||
t.start();
|
||||
t.wait(one_minute);
|
||||
|
@ -27,7 +27,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
#include <QtTest/QtTest>
|
||||
#include <qdatetime.h>
|
||||
#include <qelapsedtimer.h>
|
||||
#include <qthreadpool.h>
|
||||
#include <qstring.h>
|
||||
#include <qmutex.h>
|
||||
@ -882,7 +882,7 @@ void tst_QThreadPool::priorityStart()
|
||||
|
||||
void tst_QThreadPool::waitForDone()
|
||||
{
|
||||
QTime total, pass;
|
||||
QElapsedTimer total, pass;
|
||||
total.start();
|
||||
|
||||
QThreadPool threadPool;
|
||||
@ -1113,7 +1113,7 @@ void tst_QThreadPool::tryTake()
|
||||
|
||||
void tst_QThreadPool::destroyingWaitsForTasksToFinish()
|
||||
{
|
||||
QTime total, pass;
|
||||
QElapsedTimer total, pass;
|
||||
total.start();
|
||||
|
||||
while (total.elapsed() < 10000) {
|
||||
@ -1204,7 +1204,7 @@ void tst_QThreadPool::stressTest()
|
||||
}
|
||||
};
|
||||
|
||||
QTime total;
|
||||
QElapsedTimer total;
|
||||
total.start();
|
||||
while (total.elapsed() < 30000) {
|
||||
Task t;
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include <QtNetwork/private/qnetworksession_p.h>
|
||||
#include <QTcpServer>
|
||||
#include <QHostInfo>
|
||||
#include <QElapsedTimer>
|
||||
#include <QTcpSocket>
|
||||
|
||||
#include "../../../network-settings.h"
|
||||
@ -2160,7 +2161,7 @@ void tst_QFtp::qtbug7359Crash()
|
||||
QFtp ftp;
|
||||
ftp.connectToHost("127.0.0.1");
|
||||
|
||||
QTime t;
|
||||
QElapsedTimer t;
|
||||
int elapsed;
|
||||
|
||||
t.start();
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <QtCore/QDataStream>
|
||||
#include <QtCore/QUrl>
|
||||
#include <QtCore/QEventLoop>
|
||||
#include <QtCore/QElapsedTimer>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QRandomGenerator>
|
||||
#include <QtCore/QRegularExpression>
|
||||
@ -1149,7 +1150,7 @@ protected:
|
||||
}
|
||||
|
||||
// now write in "blocking mode", this is where the rate measuring starts
|
||||
QTime timer;
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
//const qint64 writtenBefore = dataIndex;
|
||||
//qint64 measuredTotalBytes = wantedSize - writtenBefore;
|
||||
@ -1248,7 +1249,7 @@ protected:
|
||||
}
|
||||
|
||||
qint64 bytesRead = 0;
|
||||
QTime stopWatch;
|
||||
QElapsedTimer stopWatch;
|
||||
stopWatch.start();
|
||||
do {
|
||||
if (device->bytesAvailable() == 0) {
|
||||
@ -5153,8 +5154,8 @@ void tst_QNetworkReply::ioGetFromBuiltinHttp()
|
||||
const int rate = 200; // in kB per sec
|
||||
RateControlledReader reader(server, reply.data(), rate, bufferSize);
|
||||
|
||||
QTime loopTime;
|
||||
loopTime.start();
|
||||
QElapsedTimer loopTimer;
|
||||
loopTimer.start();
|
||||
|
||||
const int result = waitForFinish(reply);
|
||||
if (notEnoughDataForFastSender) {
|
||||
@ -5164,7 +5165,7 @@ void tst_QNetworkReply::ioGetFromBuiltinHttp()
|
||||
|
||||
QVERIFY2(result == Success, msgWaitForFinished(reply));
|
||||
|
||||
const int elapsedTime = loopTime.elapsed();
|
||||
const int elapsedTime = loopTimer.elapsed();
|
||||
server.wait();
|
||||
reader.wrapUp();
|
||||
|
||||
@ -5450,12 +5451,12 @@ void tst_QNetworkReply::rateControl()
|
||||
RateControlledReader reader(sender, reply.data(), rate, 20);
|
||||
|
||||
// this test is designed to run for 25 seconds at most
|
||||
QTime loopTime;
|
||||
loopTime.start();
|
||||
QElapsedTimer loopTimer;
|
||||
loopTimer.start();
|
||||
|
||||
QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
|
||||
|
||||
int elapsedTime = loopTime.elapsed();
|
||||
int elapsedTime = loopTimer.elapsed();
|
||||
|
||||
if (!errorSpy.isEmpty()) {
|
||||
qDebug() << "ERROR!" << errorSpy[0][0] << reply->errorString();
|
||||
@ -6125,8 +6126,8 @@ void tst_QNetworkReply::httpConnectionCount()
|
||||
}
|
||||
|
||||
int pendingConnectionCount = 0;
|
||||
QTime time;
|
||||
time.start();
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
|
||||
while(pendingConnectionCount <= 20) {
|
||||
QTestEventLoop::instance().enterLoop(1);
|
||||
@ -6138,7 +6139,7 @@ void tst_QNetworkReply::httpConnectionCount()
|
||||
}
|
||||
|
||||
// at max. wait 10 sec
|
||||
if (time.elapsed() > 10000)
|
||||
if (timer.elapsed() > 10000)
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include <qcoreapplication.h>
|
||||
#include <qdatastream.h>
|
||||
#include <qhostaddress.h>
|
||||
#include <qdatetime.h>
|
||||
#include <qelapsedtimer.h>
|
||||
|
||||
#ifdef Q_OS_UNIX
|
||||
#include <unistd.h>
|
||||
@ -403,7 +403,7 @@ void tst_PlatformSocketEngine::udpLoopbackPerformance()
|
||||
QHostAddress localhost = QHostAddress::LocalHost;
|
||||
|
||||
qlonglong readBytes = 0;
|
||||
QTime timer;
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
while (timer.elapsed() < 5000) {
|
||||
udpSocket2.write(message1.data(), message1.size());
|
||||
@ -462,7 +462,7 @@ void tst_PlatformSocketEngine::tcpLoopbackPerformance()
|
||||
QByteArray message1(messageSize, '@');
|
||||
QByteArray answer(messageSize, '@');
|
||||
|
||||
QTime timer;
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
qlonglong readBytes = 0;
|
||||
while (timer.elapsed() < 5000) {
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include <qhostaddress.h>
|
||||
#include <qtcpsocket.h>
|
||||
#include <qdebug.h>
|
||||
#include <qelapsedtimer.h>
|
||||
#include <qtcpserver.h>
|
||||
|
||||
#include "../../../network-settings.h"
|
||||
@ -397,7 +398,7 @@ void tst_QHttpSocketEngine::tcpLoopbackPerformance()
|
||||
QByteArray message1(messageSize, '@');
|
||||
QByteArray answer(messageSize, '@');
|
||||
|
||||
QTime timer;
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
qlonglong readBytes = 0;
|
||||
while (timer.elapsed() < 30000) {
|
||||
@ -629,7 +630,7 @@ void tst_QHttpSocketEngine::downloadBigFile()
|
||||
|
||||
bytesAvailable = 0;
|
||||
|
||||
QTime stopWatch;
|
||||
QElapsedTimer stopWatch;
|
||||
stopWatch.start();
|
||||
|
||||
QTestEventLoop::instance().enterLoop(60);
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
#include <qtextstream.h>
|
||||
#include <qdatastream.h>
|
||||
#include <qelapsedtimer.h>
|
||||
#include <QtNetwork/qlocalsocket.h>
|
||||
#include <QtNetwork/qlocalserver.h>
|
||||
|
||||
@ -1031,7 +1032,7 @@ void tst_QLocalSocket::waitForDisconnect()
|
||||
QLocalSocket *serverSocket = server.nextPendingConnection();
|
||||
QVERIFY(serverSocket);
|
||||
socket.disconnectFromServer();
|
||||
QTime timer;
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
QVERIFY(serverSocket->waitForDisconnected(3000));
|
||||
QVERIFY(timer.elapsed() < 2000);
|
||||
|
@ -66,7 +66,7 @@
|
||||
#endif
|
||||
#include <QTextStream>
|
||||
#include <QThread>
|
||||
#include <QTime>
|
||||
#include <QElapsedTimer>
|
||||
#include <QTimer>
|
||||
#include <QDebug>
|
||||
// RVCT compiles also unused inline methods
|
||||
@ -237,7 +237,6 @@ private:
|
||||
qint64 bytesAvailable;
|
||||
qint64 expectedLength;
|
||||
bool readingBody;
|
||||
QTime timer;
|
||||
|
||||
QByteArray expectedReplyIMAP_cached;
|
||||
|
||||
@ -1518,7 +1517,7 @@ void tst_QTcpSocket::downloadBigFile()
|
||||
expectedLength = 0;
|
||||
readingBody = false;
|
||||
|
||||
QTime stopWatch;
|
||||
QElapsedTimer stopWatch;
|
||||
stopWatch.start();
|
||||
|
||||
enterLoop(600);
|
||||
@ -2482,7 +2481,7 @@ void tst_QTcpSocket::suddenRemoteDisconnect()
|
||||
QEventLoop loop;
|
||||
connect(&serverProcess, SIGNAL(finished(int)), &loop, SLOT(quit()));
|
||||
connect(&clientProcess, SIGNAL(finished(int)), &loop, SLOT(quit()));
|
||||
QTime stopWatch;
|
||||
QElapsedTimer stopWatch;
|
||||
stopWatch.start();
|
||||
QTimer::singleShot(20000, &loop, SLOT(quit()));
|
||||
|
||||
@ -2522,7 +2521,7 @@ void tst_QTcpSocket::connectToMultiIP()
|
||||
// rationale: this domain resolves to 3 A-records, 2 of them are
|
||||
// invalid. QTcpSocket should never spend more than 30 seconds per IP, and
|
||||
// 30s*2 = 60s.
|
||||
QTime stopWatch;
|
||||
QElapsedTimer stopWatch;
|
||||
stopWatch.start();
|
||||
socket->connectToHost("multi.dev.qt-project.org", 80);
|
||||
QVERIFY(socket->waitForConnected(60500));
|
||||
@ -2714,7 +2713,7 @@ void tst_QTcpSocket::taskQtBug5799ConnectionErrorWaitForConnected()
|
||||
|
||||
QTcpSocket socket;
|
||||
socket.connectToHost(QtNetworkSettings::httpServerName(), 12346);
|
||||
QTime timer;
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
socket.waitForConnected(10000);
|
||||
QVERIFY2(timer.elapsed() < 9900, "Connection to closed port timed out instead of refusing, something is wrong");
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include <qhostinfo.h>
|
||||
#include <qtcpsocket.h>
|
||||
#include <qmap.h>
|
||||
#include <qelapsedtimer.h>
|
||||
#include <qnetworkdatagram.h>
|
||||
#include <QNetworkProxy>
|
||||
#include <QNetworkInterface>
|
||||
@ -922,7 +923,7 @@ void tst_QUdpSocket::performance()
|
||||
client.connectToHost(serverAddress, server.localPort());
|
||||
QVERIFY(client.waitForConnected(10000));
|
||||
|
||||
QTime stopWatch;
|
||||
QElapsedTimer stopWatch;
|
||||
stopWatch.start();
|
||||
|
||||
qint64 nbytes = 0;
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
#include <QtCore/qthread.h>
|
||||
#include <QtCore/qelapsedtimer.h>
|
||||
#include <QtNetwork/qhostaddress.h>
|
||||
#include <QtNetwork/qhostinfo.h>
|
||||
#include <QtNetwork/qnetworkproxy.h>
|
||||
@ -1989,7 +1990,7 @@ public slots:
|
||||
QTestEventLoop::instance().exitLoop();
|
||||
}
|
||||
void waitSomeMore(QSslSocket *socket) {
|
||||
QTime t;
|
||||
QElapsedTimer t;
|
||||
t.start();
|
||||
while (!socket->encryptedBytesAvailable()) {
|
||||
QCoreApplication::processEvents(QEventLoop::AllEvents | QEventLoop::WaitForMoreEvents, 250);
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <qpa/qplatformintegration.h>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtOpenGL/QtOpenGL>
|
||||
#include <qelapsedtimer.h>
|
||||
#include "tst_qglthreads.h"
|
||||
|
||||
#ifndef QT_OPENGL_ES_2
|
||||
@ -74,9 +75,9 @@ public:
|
||||
}
|
||||
|
||||
void run() {
|
||||
QTime time;
|
||||
time.start();
|
||||
while (time.elapsed() < RUNNING_TIME) {
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
while (timer.elapsed() < RUNNING_TIME) {
|
||||
lock();
|
||||
waitForReadyToSwap();
|
||||
|
||||
@ -291,11 +292,11 @@ public:
|
||||
}
|
||||
|
||||
void run() {
|
||||
QTime time;
|
||||
time.start();
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
failure = false;
|
||||
|
||||
while (time.elapsed() < RUNNING_TIME && !failure) {
|
||||
while (timer.elapsed() < RUNNING_TIME && !failure) {
|
||||
|
||||
m_widget->makeCurrent();
|
||||
|
||||
@ -466,13 +467,13 @@ public:
|
||||
public slots:
|
||||
void draw() {
|
||||
bool beginFailed = false;
|
||||
QTime time;
|
||||
time.start();
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
int rotAngle = 10;
|
||||
device->prepareDevice();
|
||||
QPaintDevice *paintDevice = device->realPaintDevice();
|
||||
QSize s(paintDevice->width(), paintDevice->height());
|
||||
while (time.elapsed() < RUNNING_TIME) {
|
||||
while (timer.elapsed() < RUNNING_TIME) {
|
||||
QPainter p;
|
||||
if (!p.begin(paintDevice)) {
|
||||
beginFailed = true;
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QtNetwork/QtNetwork>
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QElapsedTimer>
|
||||
#include <QtCore/QTextStream>
|
||||
#include <QtCore/QRandomGenerator>
|
||||
#include <QtCore/QStandardPaths>
|
||||
@ -195,7 +196,7 @@ static bool doSocketFlush(QTcpSocket *socket, int timeout = 4000)
|
||||
#ifndef QT_NO_SSL
|
||||
QSslSocket *sslSocket = qobject_cast<QSslSocket *>(socket);
|
||||
#endif
|
||||
QTime timer;
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
int t = timeout;
|
||||
forever {
|
||||
@ -421,7 +422,7 @@ void tst_NetworkSelfTest::serverReachability()
|
||||
QTcpSocket socket;
|
||||
socket.connectToHost(QtNetworkSettings::serverName(), 12346);
|
||||
|
||||
QTime timer;
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
socket.waitForConnected(10000);
|
||||
QVERIFY2(timer.elapsed() < 9900, "Connection to closed port timed out instead of refusing, something is wrong");
|
||||
|
@ -85,7 +85,7 @@ class RaceThread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
RaceObject *object;
|
||||
QTime stopWatch;
|
||||
QElapsedTimer stopWatch;
|
||||
|
||||
public:
|
||||
RaceThread()
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <QtSql>
|
||||
#include <QtSql/private/qsqltablemodel_p.h>
|
||||
#include <QThread>
|
||||
#include <QElapsedTimer>
|
||||
|
||||
const QString test(qTableName("test", __FILE__, QSqlDatabase())),
|
||||
test2(qTableName("test2", __FILE__, QSqlDatabase())),
|
||||
@ -1804,12 +1805,12 @@ void tst_QSqlTableModel::sqlite_bigTable()
|
||||
QSqlQuery q(db);
|
||||
QVERIFY_SQL( q, exec("create table "+bigtable+"(id int primary key, name varchar)"));
|
||||
QVERIFY_SQL( q, prepare("insert into "+bigtable+"(id, name) values (?, ?)"));
|
||||
QTime startTime;
|
||||
startTime.start();
|
||||
QElapsedTimer timing;
|
||||
timing.start();
|
||||
for (int i = 0; i < 10000; ++i) {
|
||||
q.addBindValue(i);
|
||||
q.addBindValue(QString::number(i));
|
||||
if(i%1000 == 0 && startTime.elapsed() > 5000)
|
||||
if (i % 1000 == 0 && timing.elapsed() > 5000)
|
||||
qDebug() << i << "records written";
|
||||
QVERIFY_SQL( q, exec());
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QElapsedTimer>
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
class tst_Sleep: public QObject
|
||||
@ -41,7 +42,7 @@ private slots:
|
||||
|
||||
void tst_Sleep::sleep()
|
||||
{
|
||||
QTime t;
|
||||
QElapsedTimer t;
|
||||
t.start();
|
||||
|
||||
QTest::qSleep(100);
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include <QSlider>
|
||||
#include <QStyle>
|
||||
#include <QStyleOption>
|
||||
#include <QTime>
|
||||
#include <QElapsedTimer>
|
||||
#include <QDebug>
|
||||
|
||||
#include <QtTest/private/qtesthelpers_p.h>
|
||||
@ -91,7 +91,7 @@ private slots:
|
||||
void connectedSliders();
|
||||
|
||||
private:
|
||||
void waitUntilTimeElapsed(const QTime& t, int ms);
|
||||
void waitUntilTimeElapsed(const QElapsedTimer &t, int ms);
|
||||
|
||||
QWidget *topLevel;
|
||||
Slider *slider;
|
||||
@ -2053,11 +2053,11 @@ void tst_QAbstractSlider::setValue()
|
||||
QVERIFY(sliderMovedTimeStamp < valueChangedTimeStamp);
|
||||
}
|
||||
|
||||
void tst_QAbstractSlider::waitUntilTimeElapsed(const QTime& t, int ms)
|
||||
void tst_QAbstractSlider::waitUntilTimeElapsed(const QElapsedTimer &t, int ms)
|
||||
{
|
||||
const int eps = 80;
|
||||
while (t.elapsed() < ms + eps)
|
||||
QTest::qWait(qMax(ms - t.elapsed() + eps, 25));
|
||||
QTest::qWait(qMax(int(ms - t.elapsed() + eps), 25));
|
||||
}
|
||||
|
||||
void tst_QAbstractSlider::setRepeatAction()
|
||||
@ -2073,7 +2073,7 @@ void tst_QAbstractSlider::setRepeatAction()
|
||||
QCOMPARE(spy.count(), 0);
|
||||
QCOMPARE(slider->value(), 55);
|
||||
|
||||
QTime t;
|
||||
QElapsedTimer t;
|
||||
t.start();
|
||||
QTest::qWait(300);
|
||||
QCOMPARE(spy.count(), 0);
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include <QTcpServer>
|
||||
#include <QTcpSocket>
|
||||
#include <QTimer>
|
||||
#include <QElapsedTimer>
|
||||
#include <QtDebug>
|
||||
#include <QtTest/QtTest>
|
||||
#include <QXmlDefaultHandler>
|
||||
@ -259,7 +260,7 @@ public:
|
||||
// Delibrately wait a maximum of 10 seconds for the sake
|
||||
// of the test, so it doesn't unduly hang
|
||||
const int waitTime = qMax(10000, msecs);
|
||||
QTime t;
|
||||
QElapsedTimer t;
|
||||
t.start();
|
||||
while (t.elapsed() < waitTime) {
|
||||
QCoreApplication::processEvents();
|
||||
|
Loading…
x
Reference in New Issue
Block a user