diff options
Diffstat (limited to 'tests/benchmarks/corelib')
35 files changed, 1016 insertions, 683 deletions
diff --git a/tests/benchmarks/corelib/corelib.pro b/tests/benchmarks/corelib/corelib.pro index b5781ad49e..010abd7751 100644 --- a/tests/benchmarks/corelib/corelib.pro +++ b/tests/benchmarks/corelib/corelib.pro @@ -4,7 +4,9 @@ SUBDIRS = \ json \ mimetypes \ kernel \ + text \ thread \ + time \ tools \ codecs \ plugin diff --git a/tests/benchmarks/corelib/io/qdiriterator/main.cpp b/tests/benchmarks/corelib/io/qdiriterator/main.cpp index e71daccf7d..eae752d99a 100644 --- a/tests/benchmarks/corelib/io/qdiriterator/main.cpp +++ b/tests/benchmarks/corelib/io/qdiriterator/main.cpp @@ -78,24 +78,22 @@ void tst_qdiriterator::data() } #ifdef Q_OS_WIN -static int posix_helper(const wchar_t *dirpath) +static int posix_helper(const wchar_t *dirpath, size_t length) { int count = 0; HANDLE hSearch; WIN32_FIND_DATA fd; - const size_t origDirPathLength = wcslen(dirpath); - wchar_t appendedPath[MAX_PATH]; - wcscpy(appendedPath, dirpath); - wcscat(appendedPath, L"\\*"); + Q_ASSERT(MAX_PATH > length + 3); + wcsncpy(appendedPath, dirpath, length); + wcscpy(appendedPath + length, L"\\*"); #ifndef Q_OS_WINRT hSearch = FindFirstFile(appendedPath, &fd); #else hSearch = FindFirstFileEx(appendedPath, FindExInfoStandard, &fd, FindExSearchNameMatch, NULL, FIND_FIRST_EX_LARGE_FETCH); #endif - appendedPath[origDirPathLength] = 0; if (hSearch == INVALID_HANDLE_VALUE) { qWarning("FindFirstFile failed"); @@ -107,10 +105,12 @@ static int posix_helper(const wchar_t *dirpath) !(fd.cFileName[0] == L'.' && fd.cFileName[1] == L'.' && fd.cFileName[2] == 0)) { if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - wcscat(appendedPath, L"\\"); - wcscat(appendedPath, fd.cFileName); - count += posix_helper(appendedPath); - appendedPath[origDirPathLength] = 0; + // newLength will "point" to where we put a * earlier, so we overwrite that. + size_t newLength = length + 1; // "+ 1" for directory separator + Q_ASSERT(newLength + wcslen(fd.cFileName) + 1 < MAX_PATH); // "+ 1" for null-terminator + wcscpy(appendedPath + newLength, fd.cFileName); + newLength += wcslen(fd.cFileName); + count += posix_helper(appendedPath, newLength); } else { ++count; @@ -164,8 +164,8 @@ void tst_qdiriterator::posix() QBENCHMARK { #ifdef Q_OS_WIN wchar_t wPath[MAX_PATH]; - path.toWCharArray(wPath); - count = posix_helper(wPath); + const int end = path.toWCharArray(wPath); + count = posix_helper(wPath, end); #else count = posix_helper(dirpath.constData()); #endif diff --git a/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp b/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp index d68264b78f..6ee8b4e93b 100644 --- a/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp +++ b/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp @@ -218,8 +218,9 @@ void QFileSystemIteratorPrivate::pushSubDirectory(const QByteArray &path) #ifdef Q_OS_WIN wchar_t szSearchPath[MAX_PATH]; - QString::fromLatin1(path).toWCharArray(szSearchPath); - wcscat(szSearchPath, L"\\*"); + const int end = QString::fromLatin1(path + "\\*").toWCharArray(szSearchPath); + Q_ASSERT(end < MAX_PATH); + szSearchPath[end] = L'\0'; #ifndef Q_OS_WINRT HANDLE dir = FindFirstFile(szSearchPath, &m_fileSearchResult); #else diff --git a/tests/benchmarks/corelib/kernel/kernel.pro b/tests/benchmarks/corelib/kernel/kernel.pro index 02eeeaa254..92f7174419 100644 --- a/tests/benchmarks/corelib/kernel/kernel.pro +++ b/tests/benchmarks/corelib/kernel/kernel.pro @@ -5,7 +5,8 @@ SUBDIRS = \ qmetatype \ qobject \ qvariant \ - qcoreapplication + qcoreapplication \ + qtimer_vs_qmetaobject !qtHaveModule(widgets): SUBDIRS -= \ qmetaobject \ diff --git a/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp index 66a29780f0..6af5b8d586 100644 --- a/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp +++ b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp @@ -28,6 +28,7 @@ #include <QtCore> #include <QtTest/QtTest> +#include <QThread> #define INVOKE_COUNT 10000 @@ -35,8 +36,10 @@ class qtimer_vs_qmetaobject : public QObject { Q_OBJECT private slots: - void testZeroTimerSingleShot(); - void testQueuedInvokeMethod(); + void bench(); + void bench_data(); + void benchBackgroundThread(); + void benchBackgroundThread_data() { bench_data(); } }; class InvokeCounter : public QObject { @@ -47,36 +50,89 @@ public slots: void invokeSlot() { count++; if (count == INVOKE_COUNT) - QTestEventLoop::instance().exitLoop(); + emit allInvoked(); } +signals: + void allInvoked(); protected: int count; }; -void qtimer_vs_qmetaobject::testZeroTimerSingleShot() +void qtimer_vs_qmetaobject::bench() { + QFETCH(int, type); + + std::function<void(InvokeCounter*)> invoke; + if (type == 0) { + invoke = [](InvokeCounter* invokeCounter) { + QTimer::singleShot(0, invokeCounter, SLOT(invokeSlot())); + }; + } else if (type == 1) { + invoke = [](InvokeCounter* invokeCounter) { + QTimer::singleShot(0, invokeCounter, &InvokeCounter::invokeSlot); + }; + } else if (type == 2) { + invoke = [](InvokeCounter* invokeCounter) { + QTimer::singleShot(0, invokeCounter, [invokeCounter]() { + invokeCounter->invokeSlot(); + }); + }; + } else if (type == 3) { + invoke = [](InvokeCounter* invokeCounter) { + QTimer::singleShot(0, [invokeCounter]() { + invokeCounter->invokeSlot(); + }); + }; + } else if (type == 4) { + invoke = [](InvokeCounter* invokeCounter) { + QMetaObject::invokeMethod(invokeCounter, "invokeSlot", Qt::QueuedConnection); + }; + } else if (type == 5) { + invoke = [](InvokeCounter* invokeCounter) { + QMetaObject::invokeMethod(invokeCounter, &InvokeCounter::invokeSlot, Qt::QueuedConnection); + }; + } else if (type == 6) { + invoke = [](InvokeCounter* invokeCounter) { + QMetaObject::invokeMethod(invokeCounter, [invokeCounter]() { + invokeCounter->invokeSlot(); + }, Qt::QueuedConnection); + }; + } else { + QFAIL("unhandled data tag"); + } + QBENCHMARK { InvokeCounter invokeCounter; + QSignalSpy spy(&invokeCounter, &InvokeCounter::allInvoked); for(int i = 0; i < INVOKE_COUNT; ++i) { - QTimer::singleShot(0, &invokeCounter, SLOT(invokeSlot())); + invoke(&invokeCounter); } - QTestEventLoop::instance().enterLoop(10); - QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY(spy.wait(10000)); } } -void qtimer_vs_qmetaobject::testQueuedInvokeMethod() +void qtimer_vs_qmetaobject::bench_data() { - QBENCHMARK { - InvokeCounter invokeCounter; - for(int i = 0; i < INVOKE_COUNT; ++i) { - QMetaObject::invokeMethod(&invokeCounter, "invokeSlot", Qt::QueuedConnection); - } - QTestEventLoop::instance().enterLoop(10); - QVERIFY(!QTestEventLoop::instance().timeout()); - } + QTest::addColumn<int>("type"); + QTest::addRow("singleShot_slot") << 0; + QTest::addRow("singleShot_pmf") << 1; + QTest::addRow("singleShot_functor") << 2; + QTest::addRow("singleShot_functor_noctx") << 3; + QTest::addRow("invokeMethod_string") << 4; + QTest::addRow("invokeMethod_pmf") << 5; + QTest::addRow("invokeMethod_functor") << 6; } +void qtimer_vs_qmetaobject::benchBackgroundThread() +{ +#if !QT_CONFIG(cxx11_future) + QSKIP("This test requires QThread::create"); +#else + QScopedPointer<QThread> thread(QThread::create([this]() { bench(); })); + thread->start(); + QVERIFY(thread->wait()); +#endif +} QTEST_MAIN(qtimer_vs_qmetaobject) diff --git a/tests/benchmarks/corelib/tools/qbytearray/main.cpp b/tests/benchmarks/corelib/text/qbytearray/main.cpp index e421e7436b..e421e7436b 100644 --- a/tests/benchmarks/corelib/tools/qbytearray/main.cpp +++ b/tests/benchmarks/corelib/text/qbytearray/main.cpp diff --git a/tests/benchmarks/corelib/tools/qbytearray/qbytearray.pro b/tests/benchmarks/corelib/text/qbytearray/qbytearray.pro index cf28b0247f..cf28b0247f 100644 --- a/tests/benchmarks/corelib/tools/qbytearray/qbytearray.pro +++ b/tests/benchmarks/corelib/text/qbytearray/qbytearray.pro diff --git a/tests/benchmarks/corelib/tools/qchar/main.cpp b/tests/benchmarks/corelib/text/qchar/main.cpp index 4dcf86786d..4dcf86786d 100644 --- a/tests/benchmarks/corelib/tools/qchar/main.cpp +++ b/tests/benchmarks/corelib/text/qchar/main.cpp diff --git a/tests/benchmarks/corelib/tools/qchar/qchar.pro b/tests/benchmarks/corelib/text/qchar/qchar.pro index 80a9861f48..80a9861f48 100644 --- a/tests/benchmarks/corelib/tools/qchar/qchar.pro +++ b/tests/benchmarks/corelib/text/qchar/qchar.pro diff --git a/tests/benchmarks/corelib/tools/qlocale/main.cpp b/tests/benchmarks/corelib/text/qlocale/main.cpp index 38d94af143..38d94af143 100644 --- a/tests/benchmarks/corelib/tools/qlocale/main.cpp +++ b/tests/benchmarks/corelib/text/qlocale/main.cpp diff --git a/tests/benchmarks/corelib/tools/qlocale/qlocale.pro b/tests/benchmarks/corelib/text/qlocale/qlocale.pro index e56bbe0341..e56bbe0341 100644 --- a/tests/benchmarks/corelib/tools/qlocale/qlocale.pro +++ b/tests/benchmarks/corelib/text/qlocale/qlocale.pro diff --git a/tests/benchmarks/corelib/tools/qregexp/main.cpp b/tests/benchmarks/corelib/text/qregexp/main.cpp index 798b23f2b0..798b23f2b0 100644 --- a/tests/benchmarks/corelib/tools/qregexp/main.cpp +++ b/tests/benchmarks/corelib/text/qregexp/main.cpp diff --git a/tests/benchmarks/corelib/tools/qregexp/qregexp.pro b/tests/benchmarks/corelib/text/qregexp/qregexp.pro index f64ae781a2..f64ae781a2 100644 --- a/tests/benchmarks/corelib/tools/qregexp/qregexp.pro +++ b/tests/benchmarks/corelib/text/qregexp/qregexp.pro diff --git a/tests/benchmarks/corelib/tools/qregexp/qregexp.qrc b/tests/benchmarks/corelib/text/qregexp/qregexp.qrc index a7fe13c035..a7fe13c035 100644 --- a/tests/benchmarks/corelib/tools/qregexp/qregexp.qrc +++ b/tests/benchmarks/corelib/text/qregexp/qregexp.qrc diff --git a/tests/benchmarks/corelib/tools/qstring/main.cpp b/tests/benchmarks/corelib/text/qstring/main.cpp index 826a843c10..826a843c10 100644 --- a/tests/benchmarks/corelib/tools/qstring/main.cpp +++ b/tests/benchmarks/corelib/text/qstring/main.cpp diff --git a/tests/benchmarks/corelib/tools/qstring/qstring.pro b/tests/benchmarks/corelib/text/qstring/qstring.pro index 9f5e34b915..9f5e34b915 100644 --- a/tests/benchmarks/corelib/tools/qstring/qstring.pro +++ b/tests/benchmarks/corelib/text/qstring/qstring.pro diff --git a/tests/benchmarks/corelib/tools/qstringbuilder/main.cpp b/tests/benchmarks/corelib/text/qstringbuilder/main.cpp index d0dfe3b1a7..0de6d33846 100644 --- a/tests/benchmarks/corelib/tools/qstringbuilder/main.cpp +++ b/tests/benchmarks/corelib/text/qstringbuilder/main.cpp @@ -401,7 +401,7 @@ private slots: } private: - const QLatin1Literal l1literal; + const QLatin1String l1literal; const QLatin1String l1string; const QByteArray ba; const QString string; diff --git a/tests/benchmarks/corelib/tools/qstringbuilder/qstringbuilder.pro b/tests/benchmarks/corelib/text/qstringbuilder/qstringbuilder.pro index fa4cbe3c13..fa4cbe3c13 100644 --- a/tests/benchmarks/corelib/tools/qstringbuilder/qstringbuilder.pro +++ b/tests/benchmarks/corelib/text/qstringbuilder/qstringbuilder.pro diff --git a/tests/benchmarks/corelib/tools/qstringlist/.gitignore b/tests/benchmarks/corelib/text/qstringlist/.gitignore index 3e0cdc952f..3e0cdc952f 100644 --- a/tests/benchmarks/corelib/tools/qstringlist/.gitignore +++ b/tests/benchmarks/corelib/text/qstringlist/.gitignore diff --git a/tests/benchmarks/corelib/tools/qstringlist/main.cpp b/tests/benchmarks/corelib/text/qstringlist/main.cpp index ae355a8b89..ae355a8b89 100644 --- a/tests/benchmarks/corelib/tools/qstringlist/main.cpp +++ b/tests/benchmarks/corelib/text/qstringlist/main.cpp diff --git a/tests/benchmarks/corelib/tools/qstringlist/qstringlist.pro b/tests/benchmarks/corelib/text/qstringlist/qstringlist.pro index 5803e7da0e..5803e7da0e 100644 --- a/tests/benchmarks/corelib/tools/qstringlist/qstringlist.pro +++ b/tests/benchmarks/corelib/text/qstringlist/qstringlist.pro diff --git a/tests/benchmarks/corelib/text/text.pro b/tests/benchmarks/corelib/text/text.pro new file mode 100644 index 0000000000..a2397b37fe --- /dev/null +++ b/tests/benchmarks/corelib/text/text.pro @@ -0,0 +1,9 @@ +TEMPLATE = subdirs +SUBDIRS = \ + qbytearray \ + qchar \ + qlocale \ + qstringbuilder \ + qstringlist + +*g++*: SUBDIRS += qstring diff --git a/tests/benchmarks/corelib/thread/qreadwritelock/qreadwritelock.pro b/tests/benchmarks/corelib/thread/qreadwritelock/qreadwritelock.pro index 86102adecd..a1827d0276 100644 --- a/tests/benchmarks/corelib/thread/qreadwritelock/qreadwritelock.pro +++ b/tests/benchmarks/corelib/thread/qreadwritelock/qreadwritelock.pro @@ -1,6 +1,7 @@ TEMPLATE = app TARGET = tst_bench_qreadwritelock -QT = core testlib +QT = core-private testlib SOURCES += tst_qreadwritelock.cpp CONFIG += c++14 # for std::shared_timed_mutex +CONFIG += c++1z # for std::shared_mutex diff --git a/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp b/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp index fcf600a059..1d47d98657 100644 --- a/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp +++ b/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp @@ -28,12 +28,14 @@ #include <QtCore/QtCore> #include <QtTest/QtTest> +#include <QtCore/private/qmemory_p.h> #include <mutex> #if QT_HAS_INCLUDE(<shared_mutex>) #if __cplusplus > 201103L #include <shared_mutex> #endif #endif +#include <vector> // Wrapers that take pointers instead of reference to have the same interface as Qt template <typename T> @@ -63,6 +65,8 @@ private slots: void uncontended(); void readOnly_data(); void readOnly(); + void writeOnly_data(); + void writeOnly(); // void readWrite(); }; @@ -106,6 +110,14 @@ void tst_QReadWriteLock::uncontended_data() << FunctionPtrHolder(testUncontended<QReadWriteLock, QWriteLocker>); QTest::newRow("std::mutex") << FunctionPtrHolder( testUncontended<std::mutex, LockerWrapper<std::unique_lock<std::mutex>>>); +#ifdef __cpp_lib_shared_mutex + QTest::newRow("std::shared_mutex, read") << FunctionPtrHolder( + testUncontended<std::shared_mutex, + LockerWrapper<std::shared_lock<std::shared_mutex>>>); + QTest::newRow("std::shared_mutex, write") << FunctionPtrHolder( + testUncontended<std::shared_mutex, + LockerWrapper<std::unique_lock<std::shared_mutex>>>); +#endif #if defined __cpp_lib_shared_timed_mutex QTest::newRow("std::shared_timed_mutex, read") << FunctionPtrHolder( testUncontended<std::shared_timed_mutex, @@ -130,7 +142,7 @@ void testReadOnly() struct Thread : QThread { Mutex *lock; - void run() + void run() override { for (int i = 0; i < Iterations; ++i) { QString s = QString::number(i); // Do something outside the lock @@ -140,21 +152,20 @@ void testReadOnly() } }; Mutex lock; - QVector<QThread *> threads; + std::vector<std::unique_ptr<Thread>> threads; for (int i = 0; i < threadCount; ++i) { - auto t = new Thread; + auto t = qt_make_unique<Thread>(); t->lock = &lock; - threads.append(t); + threads.push_back(std::move(t)); } QBENCHMARK { - for (auto t : threads) { + for (auto &t : threads) { t->start(); } - for (auto t : threads) { + for (auto &t : threads) { t->wait(); } } - qDeleteAll(threads); } void tst_QReadWriteLock::readOnly_data() @@ -166,6 +177,11 @@ void tst_QReadWriteLock::readOnly_data() QTest::newRow("QReadWriteLock") << FunctionPtrHolder(testReadOnly<QReadWriteLock, QReadLocker>); QTest::newRow("std::mutex") << FunctionPtrHolder( testReadOnly<std::mutex, LockerWrapper<std::unique_lock<std::mutex>>>); +#ifdef __cpp_lib_shared_mutex + QTest::newRow("std::shared_mutex") << FunctionPtrHolder( + testReadOnly<std::shared_mutex, + LockerWrapper<std::shared_lock<std::shared_mutex>>>); +#endif #if defined __cpp_lib_shared_timed_mutex QTest::newRow("std::shared_timed_mutex") << FunctionPtrHolder( testReadOnly<std::shared_timed_mutex, @@ -179,5 +195,66 @@ void tst_QReadWriteLock::readOnly() holder.value(); } +static QString global_string; + +template <typename Mutex, typename Locker> +void testWriteOnly() +{ + struct Thread : QThread + { + Mutex *lock; + void run() override + { + for (int i = 0; i < Iterations; ++i) { + QString s = QString::number(i); // Do something outside the lock + Locker locker(lock); + global_string = s; + } + } + }; + Mutex lock; + std::vector<std::unique_ptr<Thread>> threads; + for (int i = 0; i < threadCount; ++i) { + auto t = qt_make_unique<Thread>(); + t->lock = &lock; + threads.push_back(std::move(t)); + } + QBENCHMARK { + for (auto &t : threads) { + t->start(); + } + for (auto &t : threads) { + t->wait(); + } + } +} + +void tst_QReadWriteLock::writeOnly_data() +{ + QTest::addColumn<FunctionPtrHolder>("holder"); + + // QTest::newRow("nothing") << FunctionPtrHolder(testWriteOnly<int, FakeLock>); + QTest::newRow("QMutex") << FunctionPtrHolder(testWriteOnly<QMutex, QMutexLocker>); + QTest::newRow("QReadWriteLock") << FunctionPtrHolder(testWriteOnly<QReadWriteLock, QWriteLocker>); + QTest::newRow("std::mutex") << FunctionPtrHolder( + testWriteOnly<std::mutex, LockerWrapper<std::unique_lock<std::mutex>>>); +#ifdef __cpp_lib_shared_mutex + QTest::newRow("std::shared_mutex") << FunctionPtrHolder( + testWriteOnly<std::shared_mutex, + LockerWrapper<std::unique_lock<std::shared_mutex>>>); +#endif +#if defined __cpp_lib_shared_timed_mutex + QTest::newRow("std::shared_timed_mutex") << FunctionPtrHolder( + testWriteOnly<std::shared_timed_mutex, + LockerWrapper<std::unique_lock<std::shared_timed_mutex>>>); +#endif +} + +void tst_QReadWriteLock::writeOnly() +{ + QFETCH(FunctionPtrHolder, holder); + holder.value(); +} + QTEST_MAIN(tst_QReadWriteLock) #include "tst_qreadwritelock.moc" diff --git a/tests/benchmarks/corelib/time/qdate/qdate.pro b/tests/benchmarks/corelib/time/qdate/qdate.pro new file mode 100644 index 0000000000..a655917135 --- /dev/null +++ b/tests/benchmarks/corelib/time/qdate/qdate.pro @@ -0,0 +1,4 @@ +TARGET = tst_bench_qdate +QT = core testlib + +SOURCES += tst_bench_qdate.cpp diff --git a/tests/benchmarks/corelib/time/qdate/tst_bench_qdate.cpp b/tests/benchmarks/corelib/time/qdate/tst_bench_qdate.cpp new file mode 100644 index 0000000000..10c013c080 --- /dev/null +++ b/tests/benchmarks/corelib/time/qdate/tst_bench_qdate.cpp @@ -0,0 +1,213 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QDate> +#include <QTest> +#include <QVector> + +class tst_QDate : public QObject +{ + Q_OBJECT + + enum : qint64 + { + JULIAN_DAY_2010 = 2455198, + JULIAN_DAY_2011 = 2455563, + JULIAN_DAY_2020 = 2458850, + }; + + static QVector<QDate> daily(qint64 start, qint64 end); + static QVector<QDate> yearly(qint32 first, qint32 last); + +private Q_SLOTS: + void create(); + void year(); + void month(); + void day(); + void dayOfWeek(); + void dayOfYear(); + void monthLengths(); // isValid() and daysInMonth() + void daysInYear(); + void isLeapYear(); + void getSetDate(); + void addDays(); + void addMonths(); + void addYears(); +}; + +QVector<QDate> tst_QDate::daily(qint64 start, qint64 end) +{ + QVector<QDate> list; + list.reserve(end - start); + for (qint64 jd = start; jd < end; ++jd) + list.append(QDate::fromJulianDay(jd)); + return list; +} + +QVector<QDate> tst_QDate::yearly(qint32 first, qint32 last) +{ + QVector<QDate> list; + list.reserve(last + 1 - first); + for (qint32 year = first; year <= last; ++year) + list.append(QDate(year, 3, 21)); + return list; +} + +void tst_QDate::create() +{ + QDate test; + QBENCHMARK { + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + test = QDate::fromJulianDay(jd); + } + Q_UNUSED(test); +} + +void tst_QDate::year() +{ + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const QDate &test : list) + test.year(); + } +} + +void tst_QDate::month() +{ + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const QDate &test : list) + test.month(); + } +} + +void tst_QDate::day() +{ + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const QDate &test : list) + test.day(); + } +} + +void tst_QDate::dayOfWeek() +{ + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const QDate &test : list) + test.dayOfWeek(); + } +} + +void tst_QDate::dayOfYear() +{ + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const QDate &test : list) + test.dayOfYear(); + } +} + +void tst_QDate::monthLengths() +{ + bool check = true; + QBENCHMARK { + for (int year = 1900; year <= 2100; year++) { + for (int month = 1; month <= 12; month++) + check = QDate::isValid(year, month, QDate(year, month, 1).daysInMonth()); + } + } + Q_UNUSED(check); +} + +void tst_QDate::daysInYear() +{ + const auto list = yearly(1601, 2401); + QBENCHMARK { + for (const QDate date : list) + date.daysInYear(); + } +} + +void tst_QDate::isLeapYear() +{ + QBENCHMARK { + for (qint32 year = 1601; year <= 2401; year++) + QDate::isLeapYear(year); + } +} + +void tst_QDate::getSetDate() +{ + QDate store; + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const auto test : list) { + int year, month, day; + test.getDate(&year, &month, &day); + store.setDate(year, month, day); + } + } + Q_UNUSED(store); +} + +void tst_QDate::addDays() +{ + QDate store; + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const auto test : list) + store = test.addDays(17); + } + Q_UNUSED(store); +} + +void tst_QDate::addMonths() +{ + QDate store; + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const auto test : list) + store = test.addMonths(17); + } + Q_UNUSED(store); +} + +void tst_QDate::addYears() +{ + QDate store; + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const auto test : list) + store = test.addYears(17); + } + Q_UNUSED(store); +} + +QTEST_MAIN(tst_QDate) +#include "tst_bench_qdate.moc" diff --git a/tests/benchmarks/corelib/time/qdatetime/main.cpp b/tests/benchmarks/corelib/time/qdatetime/main.cpp new file mode 100644 index 0000000000..740e08cc46 --- /dev/null +++ b/tests/benchmarks/corelib/time/qdatetime/main.cpp @@ -0,0 +1,574 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QDateTime> +#include <QTimeZone> +#include <QTest> +#include <QVector> +#include <qdebug.h> + +class tst_QDateTime : public QObject +{ + Q_OBJECT + + enum : qint64 + { + SECS_PER_DAY = 86400, + MSECS_PER_DAY = 86400000, + JULIAN_DAY_1950 = 2433283, + JULIAN_DAY_1960 = 2436935, + JULIAN_DAY_1970 = 2440588, // Epoch + JULIAN_DAY_2010 = 2455198, + JULIAN_DAY_2011 = 2455563, + JULIAN_DAY_2020 = 2458850, + JULIAN_DAY_2050 = 2469808, + JULIAN_DAY_2060 = 2473460 + }; + + static QVector<QDateTime> daily(qint64 start, qint64 end); + static QVector<QDateTime> norse(qint64 start, qint64 end); + +private Q_SLOTS: + void create(); + void isNull(); + void isValid(); + void date(); + void time(); + void timeSpec(); + void offsetFromUtc(); + void timeZoneAbbreviation(); + void toMSecsSinceEpoch(); + void toMSecsSinceEpoch1950(); + void toMSecsSinceEpoch2050(); + void toMSecsSinceEpochTz(); + void toMSecsSinceEpoch1950Tz(); + void toMSecsSinceEpoch2050Tz(); + void setDate(); + void setTime(); + void setTimeSpec(); + void setOffsetFromUtc(); + void setMSecsSinceEpoch(); + void setMSecsSinceEpochTz(); + void toString(); + void toStringTextFormat(); + void toStringIsoFormat(); + void addDays(); + void addDaysTz(); + void addMSecs(); + void addMSecsTz(); + void toTimeSpec(); + void toOffsetFromUtc(); + void daysTo(); + void msecsTo(); + void equivalent(); + void equivalentUtc(); + void lessThan(); + void lessThanUtc(); + void currentDateTime(); + void currentDate(); + void currentTime(); + void currentDateTimeUtc(); + void currentMSecsSinceEpoch(); + void fromString(); + void fromStringText(); + void fromStringIso(); + void fromMSecsSinceEpoch(); + void fromMSecsSinceEpochUtc(); + void fromMSecsSinceEpochTz(); +}; + +QVector<QDateTime> tst_QDateTime::daily(qint64 start, qint64 end) +{ + QVector<QDateTime> list; + list.reserve(end - start); + for (int jd = start; jd < end; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + return list; +} + +QVector<QDateTime> tst_QDateTime::norse(qint64 start, qint64 end) +{ + const QTimeZone cet("Europe/Oslo"); + QVector<QDateTime> list; + list.reserve(end - start); + for (int jd = start; jd < end; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet)); + return list; +} + +void tst_QDateTime::create() +{ + QBENCHMARK { + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) { + QDateTime test(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)); + Q_UNUSED(test) + } + } +} + +void tst_QDateTime::isNull() +{ + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const QDateTime &test : list) + test.isNull(); + } +} + +void tst_QDateTime::isValid() +{ + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const QDateTime &test : list) + test.isValid(); + } +} + +void tst_QDateTime::date() +{ + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const QDateTime &test : list) + test.date(); + } +} + +void tst_QDateTime::time() +{ + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const QDateTime &test : list) + test.time(); + } +} + +void tst_QDateTime::timeSpec() +{ + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const QDateTime &test : list) + test.timeSpec(); + } +} + +void tst_QDateTime::offsetFromUtc() +{ + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const QDateTime &test : list) + test.offsetFromUtc(); + } +} + +void tst_QDateTime::timeZoneAbbreviation() +{ + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const QDateTime &test : list) + test.timeZoneAbbreviation(); + } +} + +void tst_QDateTime::toMSecsSinceEpoch() +{ + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const QDateTime &test : list) + test.toMSecsSinceEpoch(); + } +} + +void tst_QDateTime::toMSecsSinceEpoch1950() +{ + const auto list = daily(JULIAN_DAY_1950, JULIAN_DAY_1960); + QBENCHMARK { + for (const QDateTime &test : list) + test.toMSecsSinceEpoch(); + } +} + +void tst_QDateTime::toMSecsSinceEpoch2050() +{ + const auto list = daily(JULIAN_DAY_2050, JULIAN_DAY_2060); + QBENCHMARK { + for (const QDateTime &test : list) + test.toMSecsSinceEpoch(); + } +} + +void tst_QDateTime::toMSecsSinceEpochTz() +{ + qint64 result; + const auto list = norse(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const QDateTime &test : list) + result = test.toMSecsSinceEpoch(); + } + Q_UNUSED(result); +} + +void tst_QDateTime::toMSecsSinceEpoch1950Tz() +{ + qint64 result; + const auto list = norse(JULIAN_DAY_1950, JULIAN_DAY_1960); + QBENCHMARK { + for (const QDateTime &test : list) + result = test.toMSecsSinceEpoch(); + } + Q_UNUSED(result); +} + +void tst_QDateTime::toMSecsSinceEpoch2050Tz() +{ + qint64 result; + const auto list = norse(JULIAN_DAY_2050, JULIAN_DAY_2060); + QBENCHMARK { + for (const QDateTime &test : list) + result = test.toMSecsSinceEpoch(); + } + Q_UNUSED(result); +} + +void tst_QDateTime::setDate() +{ + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (QDateTime test : list) + test.setDate(QDate::fromJulianDay(JULIAN_DAY_2010)); + } +} + +void tst_QDateTime::setTime() +{ + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (QDateTime test : list) + test.setTime(QTime(12, 0, 0)); + } +} + +void tst_QDateTime::setTimeSpec() +{ + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (QDateTime test : list) + test.setTimeSpec(Qt::UTC); + } +} + +void tst_QDateTime::setOffsetFromUtc() +{ + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (QDateTime test : list) + test.setOffsetFromUtc(3600); + } +} + +void tst_QDateTime::setMSecsSinceEpoch() +{ + qint64 msecs = qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970 + 180) * MSECS_PER_DAY; + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (QDateTime test : list) + test.setMSecsSinceEpoch(msecs); + } +} + +void tst_QDateTime::setMSecsSinceEpochTz() +{ + const qint64 msecs = qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970 + 180) * MSECS_PER_DAY; + const auto list = norse(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (QDateTime test : list) + test.setMSecsSinceEpoch(msecs); + } +} + +void tst_QDateTime::toString() +{ + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2011); + QBENCHMARK { + for (const QDateTime &test : list) + test.toString(QStringLiteral("yyy-MM-dd hh:mm:ss.zzz t")); + } +} + +void tst_QDateTime::toStringTextFormat() +{ + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2011); + QBENCHMARK { + for (const QDateTime &test : list) + test.toString(Qt::TextDate); + } +} + +void tst_QDateTime::toStringIsoFormat() +{ + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2011); + QBENCHMARK { + for (const QDateTime &test : list) + test.toString(Qt::ISODate); + } +} + +void tst_QDateTime::addDays() +{ + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QDateTime next; + QBENCHMARK { + for (const QDateTime &test : list) + next = test.addDays(1); + } + Q_UNUSED(next); +} + +void tst_QDateTime::addDaysTz() +{ + const auto list = norse(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const QDateTime &test : list) + QDateTime result = test.addDays(1); + } +} + +void tst_QDateTime::addMSecs() +{ + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QDateTime next; + QBENCHMARK { + for (const QDateTime &test : list) + next = test.addMSecs(1); + } + Q_UNUSED(next); +} + +void tst_QDateTime::addMSecsTz() +{ + const auto list = norse(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const QDateTime &test : list) + QDateTime result = test.addMSecs(1); + } +} + +void tst_QDateTime::toTimeSpec() +{ + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const QDateTime &test : list) + test.toTimeSpec(Qt::UTC); + } +} + +void tst_QDateTime::toOffsetFromUtc() +{ + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const QDateTime &test : list) + test.toOffsetFromUtc(3600); + } +} + +void tst_QDateTime::daysTo() +{ + const QDateTime other = QDateTime::fromMSecsSinceEpoch( + qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970) * MSECS_PER_DAY); + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const QDateTime &test : list) + test.daysTo(other); + } +} + +void tst_QDateTime::msecsTo() +{ + const QDateTime other = QDateTime::fromMSecsSinceEpoch( + qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970) * MSECS_PER_DAY); + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const QDateTime &test : list) + test.msecsTo(other); + } +} + +void tst_QDateTime::equivalent() +{ + bool result; + const QDateTime other = QDateTime::fromMSecsSinceEpoch( + qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970) * MSECS_PER_DAY); + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const QDateTime &test : list) + result = (test == other); + } + Q_UNUSED(result) +} + +void tst_QDateTime::equivalentUtc() +{ + bool result = false; + const QDateTime other = QDateTime::fromMSecsSinceEpoch( + qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970) * MSECS_PER_DAY, Qt::UTC); + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const QDateTime &test : list) + result = (test == other); + } + Q_UNUSED(result) +} + +void tst_QDateTime::lessThan() +{ + bool result = false; + const QDateTime other = QDateTime::fromMSecsSinceEpoch( + qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970) * MSECS_PER_DAY); + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const QDateTime &test : list) + result = (test < other); + } + Q_UNUSED(result) +} + +void tst_QDateTime::lessThanUtc() +{ + bool result = false; + const QDateTime other = QDateTime::fromMSecsSinceEpoch( + qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970) * MSECS_PER_DAY, Qt::UTC); + const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); + QBENCHMARK { + for (const QDateTime &test : list) + result = (test < other); + } + Q_UNUSED(result) +} + +void tst_QDateTime::currentDateTime() +{ + QBENCHMARK { + for (int i = 0; i < 1000; ++i) + QDateTime::currentDateTime(); + } +} + +void tst_QDateTime::currentDate() +{ + QBENCHMARK { + for (int i = 0; i < 1000; ++i) + QDate::currentDate(); + } +} + +void tst_QDateTime::currentTime() +{ + QBENCHMARK { + for (int i = 0; i < 1000; ++i) + QTime::currentTime(); + } +} + +void tst_QDateTime::currentDateTimeUtc() +{ + QBENCHMARK { + for (int i = 0; i < 1000; ++i) + QDateTime::currentDateTimeUtc(); + } +} + +void tst_QDateTime::currentMSecsSinceEpoch() +{ + QBENCHMARK { + for (int i = 0; i < 1000; ++i) + QDateTime::currentMSecsSinceEpoch(); + } +} + +void tst_QDateTime::fromString() +{ + QString format = "yyyy-MM-dd hh:mm:ss.zzz"; + QString input = "2010-01-01 13:12:11.999"; + QVERIFY(QDateTime::fromString(input, format).isValid()); + QBENCHMARK { + for (int i = 0; i < 1000; ++i) + QDateTime::fromString(input, format); + } +} + +void tst_QDateTime::fromStringText() +{ + QString input = "Wed Jan 2 01:02:03.000 2013 GMT"; + QBENCHMARK { + for (int i = 0; i < 1000; ++i) + QDateTime::fromString(input, Qt::TextDate); + } +} + +void tst_QDateTime::fromStringIso() +{ + QString input = "2010-01-01T13:28:34.999Z"; + QBENCHMARK { + for (int i = 0; i < 1000; ++i) + QDateTime::fromString(input, Qt::ISODate); + } +} + +void tst_QDateTime::fromMSecsSinceEpoch() +{ + const int start = JULIAN_DAY_2010 - JULIAN_DAY_1970; + const int end = JULIAN_DAY_2020 - JULIAN_DAY_1970; + QBENCHMARK { + for (int jd = start; jd < end; ++jd) + QDateTime::fromMSecsSinceEpoch(jd * MSECS_PER_DAY, Qt::LocalTime); + } +} + +void tst_QDateTime::fromMSecsSinceEpochUtc() +{ + const int start = JULIAN_DAY_2010 - JULIAN_DAY_1970; + const int end = JULIAN_DAY_2020 - JULIAN_DAY_1970; + QBENCHMARK { + for (int jd = start; jd < end; ++jd) + QDateTime::fromMSecsSinceEpoch(jd * MSECS_PER_DAY, Qt::UTC); + } +} + +void tst_QDateTime::fromMSecsSinceEpochTz() +{ + const int start = JULIAN_DAY_2010 - JULIAN_DAY_1970; + const int end = JULIAN_DAY_2020 - JULIAN_DAY_1970; + const QTimeZone cet("Europe/Oslo"); + QBENCHMARK { + for (int jd = start; jd < end; ++jd) + QDateTime test = QDateTime::fromMSecsSinceEpoch(jd * MSECS_PER_DAY, cet); + } +} + +QTEST_MAIN(tst_QDateTime) + +#include "main.moc" diff --git a/tests/benchmarks/corelib/tools/qdatetime/qdatetime.pro b/tests/benchmarks/corelib/time/qdatetime/qdatetime.pro index a85e7346c6..a85e7346c6 100644 --- a/tests/benchmarks/corelib/tools/qdatetime/qdatetime.pro +++ b/tests/benchmarks/corelib/time/qdatetime/qdatetime.pro diff --git a/tests/benchmarks/corelib/tools/qtimezone/main.cpp b/tests/benchmarks/corelib/time/qtimezone/main.cpp index 65455a7261..65455a7261 100644 --- a/tests/benchmarks/corelib/tools/qtimezone/main.cpp +++ b/tests/benchmarks/corelib/time/qtimezone/main.cpp diff --git a/tests/benchmarks/corelib/tools/qtimezone/qtimezone.pro b/tests/benchmarks/corelib/time/qtimezone/qtimezone.pro index d0531b568b..d0531b568b 100644 --- a/tests/benchmarks/corelib/tools/qtimezone/qtimezone.pro +++ b/tests/benchmarks/corelib/time/qtimezone/qtimezone.pro diff --git a/tests/benchmarks/corelib/time/time.pro b/tests/benchmarks/corelib/time/time.pro new file mode 100644 index 0000000000..b5184845d9 --- /dev/null +++ b/tests/benchmarks/corelib/time/time.pro @@ -0,0 +1,5 @@ +TEMPLATE = subdirs +SUBDIRS = \ + qdate \ + qdatetime \ + qtimezone diff --git a/tests/benchmarks/corelib/tools/qdatetime/main.cpp b/tests/benchmarks/corelib/tools/qdatetime/main.cpp deleted file mode 100644 index 2c1e3d97ae..0000000000 --- a/tests/benchmarks/corelib/tools/qdatetime/main.cpp +++ /dev/null @@ -1,604 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QDateTime> -#include <QTimeZone> -#include <QTest> -#include <qdebug.h> - -class tst_QDateTime : public QObject -{ - Q_OBJECT - - enum -#if defined(Q_COMPILER_CLASS_ENUM) || (defined(Q_CC_MSVC) && _MSC_VER >= 1700) - : qint64 -#endif - { - SECS_PER_DAY = 86400, - MSECS_PER_DAY = 86400000, - JULIAN_DAY_1950 = 2433283, - JULIAN_DAY_1960 = 2436935, - JULIAN_DAY_2010 = 2455198, - JULIAN_DAY_2011 = 2455563, - JULIAN_DAY_2020 = 2458850, - JULIAN_DAY_2050 = 2469808, - JULIAN_DAY_2060 = 2473460 - }; - -private Q_SLOTS: - void create(); - void isNull(); - void isValid(); - void date(); - void time(); - void timeSpec(); - void offsetFromUtc(); - void timeZoneAbbreviation(); - void toMSecsSinceEpoch(); - void toMSecsSinceEpoch1950(); - void toMSecsSinceEpoch2050(); - void toMSecsSinceEpochTz(); - void toMSecsSinceEpoch1950Tz(); - void toMSecsSinceEpoch2050Tz(); - void setDate(); - void setTime(); - void setTimeSpec(); - void setOffsetFromUtc(); - void setMSecsSinceEpoch(); - void setMSecsSinceEpochTz(); - void toString(); - void toStringTextFormat(); - void toStringIsoFormat(); - void addDays(); - void addDaysTz(); - void addMSecs(); - void addMSecsTz(); - void toTimeSpec(); - void toOffsetFromUtc(); - void daysTo(); - void msecsTo(); - void equivalent(); - void equivalentUtc(); - void lessThan(); - void lessThanUtc(); - void currentDateTime(); - void currentDate(); - void currentTime(); - void currentDateTimeUtc(); - void currentMSecsSinceEpoch(); - void fromString(); - void fromStringText(); - void fromStringIso(); - void fromMSecsSinceEpoch(); - void fromMSecsSinceEpochUtc(); - void fromMSecsSinceEpochTz(); -}; - -void tst_QDateTime::create() -{ - QBENCHMARK { - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) { - QDateTime test(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)); - Q_UNUSED(test) - } - } -} - -void tst_QDateTime::isNull() -{ - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.isNull(); - } -} - -void tst_QDateTime::isValid() -{ - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.isValid(); - } -} - -void tst_QDateTime::date() -{ - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.date(); - } -} - -void tst_QDateTime::time() -{ - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.time(); - } -} - -void tst_QDateTime::timeSpec() -{ - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.timeSpec(); - } -} - -void tst_QDateTime::offsetFromUtc() -{ - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.offsetFromUtc(); - } -} - -void tst_QDateTime::timeZoneAbbreviation() -{ - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.timeZoneAbbreviation(); - } -} - -void tst_QDateTime::toMSecsSinceEpoch() -{ - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.toMSecsSinceEpoch(); - } -} - -void tst_QDateTime::toMSecsSinceEpoch1950() -{ - QList<QDateTime> list; - for (int jd = JULIAN_DAY_1950; jd < JULIAN_DAY_1960; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.toMSecsSinceEpoch(); - } -} - -void tst_QDateTime::toMSecsSinceEpoch2050() -{ - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2050; jd < JULIAN_DAY_2060; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.toMSecsSinceEpoch(); - } -} - -void tst_QDateTime::toMSecsSinceEpochTz() -{ - QTimeZone cet = QTimeZone("Europe/Oslo"); - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet)); - QBENCHMARK { - foreach (const QDateTime &test, list) - qint64 result = test.toMSecsSinceEpoch(); - } -} - -void tst_QDateTime::toMSecsSinceEpoch1950Tz() -{ - QTimeZone cet = QTimeZone("Europe/Oslo"); - QList<QDateTime> list; - for (int jd = JULIAN_DAY_1950; jd < JULIAN_DAY_1960; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet)); - QBENCHMARK { - foreach (const QDateTime &test, list) - qint64 result = test.toMSecsSinceEpoch(); - } -} - -void tst_QDateTime::toMSecsSinceEpoch2050Tz() -{ - QTimeZone cet = QTimeZone("Europe/Oslo"); - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2050; jd < JULIAN_DAY_2060; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet)); - QBENCHMARK { - foreach (const QDateTime &test, list) - qint64 result = test.toMSecsSinceEpoch(); - } -} - -void tst_QDateTime::setDate() -{ - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (QDateTime test, list) - test.setDate(QDate::fromJulianDay(JULIAN_DAY_2010)); - } -} - -void tst_QDateTime::setTime() -{ - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (QDateTime test, list) - test.setTime(QTime(12, 0, 0)); - } -} - -void tst_QDateTime::setTimeSpec() -{ - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (QDateTime test, list) - test.setTimeSpec(Qt::UTC); - } -} - -void tst_QDateTime::setOffsetFromUtc() -{ - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (QDateTime test, list) - test.setOffsetFromUtc(3600); - } -} - -void tst_QDateTime::setMSecsSinceEpoch() -{ - qint64 msecs = qint64(JULIAN_DAY_2010 + 180) * MSECS_PER_DAY; - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (QDateTime test, list) - test.setMSecsSinceEpoch(msecs); - } -} - -void tst_QDateTime::setMSecsSinceEpochTz() -{ - QTimeZone cet = QTimeZone("Europe/Oslo"); - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet)); - QBENCHMARK { - foreach (QDateTime test, list) - test.setMSecsSinceEpoch((JULIAN_DAY_2010 + 180) * MSECS_PER_DAY); - } -} - -void tst_QDateTime::toString() -{ - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2011; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.toString(QStringLiteral("yyy-MM-dd hh:mm:ss.zzz t")); - } -} - -void tst_QDateTime::toStringTextFormat() -{ - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2011; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.toString(Qt::TextDate); - } -} - -void tst_QDateTime::toStringIsoFormat() -{ - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2011; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.toString(Qt::ISODate); - } -} - -void tst_QDateTime::addDays() -{ - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.addDays(1); - } -} - -void tst_QDateTime::addDaysTz() -{ - QTimeZone cet = QTimeZone("Europe/Oslo"); - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet)); - QBENCHMARK { - foreach (const QDateTime &test, list) - QDateTime result = test.addDays(1); - } -} - -void tst_QDateTime::addMSecs() -{ - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.addMSecs(1); - } -} - -void tst_QDateTime::addMSecsTz() -{ - QTimeZone cet = QTimeZone("Europe/Oslo"); - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet)); - QBENCHMARK { - foreach (const QDateTime &test, list) - QDateTime result = test.addMSecs(1); - } -} - -void tst_QDateTime::toTimeSpec() -{ - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.toTimeSpec(Qt::UTC); - } -} - -void tst_QDateTime::toOffsetFromUtc() -{ - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.toOffsetFromUtc(3600); - } -} - -void tst_QDateTime::daysTo() -{ - QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY); - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.daysTo(other); - } -} - -void tst_QDateTime::msecsTo() -{ - QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY); - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.msecsTo(other); - } -} - -void tst_QDateTime::equivalent() -{ - bool result; - QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY); - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - result = (test == other); - } - Q_UNUSED(result) -} - -void tst_QDateTime::equivalentUtc() -{ - bool result = false; - QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY, Qt::UTC); - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - result = (test == other); - } - Q_UNUSED(result) -} - -void tst_QDateTime::lessThan() -{ - bool result = false; - QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY); - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - result = (test < other); - } - Q_UNUSED(result) -} - -void tst_QDateTime::lessThanUtc() -{ - bool result = false; - QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY, Qt::UTC); - QList<QDateTime> list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - result = (test < other); - } - Q_UNUSED(result) -} - -void tst_QDateTime::currentDateTime() -{ - QBENCHMARK { - for (int i = 0; i < 1000; ++i) - QDateTime::currentDateTime(); - } -} - -void tst_QDateTime::currentDate() -{ - QBENCHMARK { - for (int i = 0; i < 1000; ++i) - QDate::currentDate(); - } -} - -void tst_QDateTime::currentTime() -{ - QBENCHMARK { - for (int i = 0; i < 1000; ++i) - QTime::currentTime(); - } -} - -void tst_QDateTime::currentDateTimeUtc() -{ - QBENCHMARK { - for (int i = 0; i < 1000; ++i) - QDateTime::currentDateTimeUtc(); - } -} - -void tst_QDateTime::currentMSecsSinceEpoch() -{ - QBENCHMARK { - for (int i = 0; i < 1000; ++i) - QDateTime::currentMSecsSinceEpoch(); - } -} - -void tst_QDateTime::fromString() -{ - QString format = "yyyy-MM-dd hh:mm:ss.zzz"; - QString input = "2010-01-01 13:12:11.999"; - QVERIFY(QDateTime::fromString(input, format).isValid()); - QBENCHMARK { - for (int i = 0; i < 1000; ++i) - QDateTime::fromString(input, format); - } -} - -void tst_QDateTime::fromStringText() -{ - QString input = "Wed Jan 2 01:02:03.000 2013 GMT"; - QBENCHMARK { - for (int i = 0; i < 1000; ++i) - QDateTime::fromString(input, Qt::TextDate); - } -} - -void tst_QDateTime::fromStringIso() -{ - QString input = "2010-01-01T13:28:34.999Z"; - QBENCHMARK { - for (int i = 0; i < 1000; ++i) - QDateTime::fromString(input, Qt::ISODate); - } -} - -void tst_QDateTime::fromMSecsSinceEpoch() -{ - QBENCHMARK { - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - QDateTime::fromMSecsSinceEpoch(jd * MSECS_PER_DAY, Qt::LocalTime); - } -} - -void tst_QDateTime::fromMSecsSinceEpochUtc() -{ - QBENCHMARK { - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - QDateTime::fromMSecsSinceEpoch(jd * MSECS_PER_DAY, Qt::UTC); - } -} - -void tst_QDateTime::fromMSecsSinceEpochTz() -{ - QTimeZone cet = QTimeZone("Europe/Oslo"); - QBENCHMARK { - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - QDateTime test = QDateTime::fromMSecsSinceEpoch(jd * MSECS_PER_DAY, cet); - } -} - -QTEST_MAIN(tst_QDateTime) - -#include "main.moc" diff --git a/tests/benchmarks/corelib/tools/qhash/paths_small_data.txt b/tests/benchmarks/corelib/tools/qhash/paths_small_data.txt index d5acd28820..662285296f 100644 --- a/tests/benchmarks/corelib/tools/qhash/paths_small_data.txt +++ b/tests/benchmarks/corelib/tools/qhash/paths_small_data.txt @@ -47,13 +47,38 @@ ./codecs/.obj/debug-shared ./.pch ./.pch/debug-shared +./text +./text/text.pro +./text/qregexp +./text/qregexp/qregexp.qrc +./text/qregexp/main.cpp +./text/qregexp/Makefile +./text/qregexp/qregexp.pro +./text/qstringbuilder +./text/qstringbuilder/main.cpp +./text/qstringbuilder/Makefile +./text/qstringbuilder/qstringbuilder.pro +./text/qstring +./text/qstring/generatelist.pl +./text/qstring/data.h +./text/qstring/qstring.pro +./text/qstring/main.cpp +./text/qstring/data.cpp +./text/qstring/Makefile +./text/qstring/utf-8.txt +./text/qstringlist +./text/qstringlist/qstringlist.pro +./text/qstringlist/main.cpp +./text/qstringlist/.gitignore +./text/qstringlist/Makefile +./text/qbytearray +./text/qbytearray/qbytearray.pro +./text/qbytearray/main.cpp +./text/qbytearray/Makefile +./text/.pch +./text/.pch/debug-shared ./tools ./tools/tools.pro -./tools/qregexp -./tools/qregexp/qregexp.qrc -./tools/qregexp/main.cpp -./tools/qregexp/Makefile -./tools/qregexp/qregexp.pro ./tools/qvector ./tools/qvector/tst_vector ./tools/qvector/.pch @@ -72,31 +97,10 @@ ./tools/qvector/qvector.pro ./tools/.pch ./tools/.pch/debug-shared -./tools/qstringbuilder -./tools/qstringbuilder/main.cpp -./tools/qstringbuilder/Makefile -./tools/qstringbuilder/qstringbuilder.pro ./tools/containers-sequential ./tools/containers-sequential/containers-sequential.pro ./tools/containers-sequential/main.cpp ./tools/containers-sequential/Makefile -./tools/qstring -./tools/qstring/generatelist.pl -./tools/qstring/data.h -./tools/qstring/qstring.pro -./tools/qstring/main.cpp -./tools/qstring/data.cpp -./tools/qstring/Makefile -./tools/qstring/utf-8.txt -./tools/qstringlist -./tools/qstringlist/qstringlist.pro -./tools/qstringlist/main.cpp -./tools/qstringlist/.gitignore -./tools/qstringlist/Makefile -./tools/qbytearray -./tools/qbytearray/qbytearray.pro -./tools/qbytearray/main.cpp -./tools/qbytearray/Makefile ./tools/containers-associative ./tools/containers-associative/containers-associative.pro ./tools/containers-associative/main.cpp diff --git a/tests/benchmarks/corelib/tools/qvector/qrawvector.h b/tests/benchmarks/corelib/tools/qvector/qrawvector.h index c7173b5b8d..16a911c63a 100644 --- a/tests/benchmarks/corelib/tools/qvector/qrawvector.h +++ b/tests/benchmarks/corelib/tools/qvector/qrawvector.h @@ -32,7 +32,6 @@ #include <QtCore/qiterator.h> #include <QtCore/qdebug.h> #include <QtCore/qatomic.h> -#include <QtCore/qalgorithms.h> #include <QtCore/qlist.h> #include <QtCore/private/qtools_p.h> @@ -263,9 +262,9 @@ public: //static QRawVector<T> fromList(const QList<T> &list); static inline QRawVector<T> fromStdVector(const std::vector<T> &vector) - { QRawVector<T> tmp; qCopy(vector.begin(), vector.end(), std::back_inserter(tmp)); return tmp; } + { QRawVector<T> tmp; std::copy(vector.begin(), vector.end(), std::back_inserter(tmp)); return tmp; } inline std::vector<T> toStdVector() const - { std::vector<T> tmp; qCopy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; } + { std::vector<T> tmp; std::copy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; } private: T *allocate(int alloc); @@ -568,7 +567,7 @@ typename QRawVector<T>::iterator QRawVector<T>::erase(iterator abegin, iterator int l = int(aend - m_begin); int n = l - f; if (QTypeInfo<T>::isComplex) { - qCopy(m_begin + l, m_begin + m_size, m_begin + f); + std::copy(m_begin + l, m_begin + m_size, m_begin + f); T *i = m_begin + m_size; T *b = m_begin + m_size - n; while (i != b) { diff --git a/tests/benchmarks/corelib/tools/tools.pro b/tests/benchmarks/corelib/tools/tools.pro index ca9c0a6f89..b4ee0520a6 100644 --- a/tests/benchmarks/corelib/tools/tools.pro +++ b/tests/benchmarks/corelib/tools/tools.pro @@ -2,21 +2,12 @@ TEMPLATE = subdirs SUBDIRS = \ containers-associative \ containers-sequential \ - qbytearray \ qcontiguouscache \ qcryptographichash \ - qdatetime \ qlist \ - qlocale \ qmap \ qrect \ qringbuffer \ qstack \ - qstring \ - qstringbuilder \ - qstringlist \ - qtimezone \ qvector \ qalgorithms - -!*g++*: SUBDIRS -= qstring |