summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRobin Burchell <robin+qt@viroteck.net>2012-08-15 13:37:15 +0200
committerQt by Nokia <qt-info@nokia.com>2012-08-20 16:02:03 +0200
commitb9ef4a9c3047228ec007ac81ff0a304f8cc274b7 (patch)
treeb1507f251df23ed0b8f455c48cf011e702df4520 /tests
parentf3fea329fdd4abbc2f2eec0098d0d5aae1c8cc86 (diff)
Speed up sorting of dir entries when sorted by date
QDateTime will attempt to convert unknown types of date to UTC time, which isn't exactly a fast process. As we don't care about local timezones in the process of sorting (as this is purely for ordering, not display to the end user), we can force the dates to use UTC time, avoiding the unnecessary local timezone lookup. This also adds a benchmark covering this case. Benchmark results, Qt 5: - before: 11, 489ms - after: 273ms Qt 4.8: - before: 20, 848ms - after: 278ms Change-Id: I87fa6260e820b5b172d3306ff395dafe767c33ff Reported-by: Thomas Perl <m@thp.io> Reviewed-by: Alberto Mardegan <mardy@users.sourceforge.net> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/benchmarks/corelib/io/qdir/10000/bench_qdir_10000.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/benchmarks/corelib/io/qdir/10000/bench_qdir_10000.cpp b/tests/benchmarks/corelib/io/qdir/10000/bench_qdir_10000.cpp
index 2de98eff0b..d741ae795c 100644
--- a/tests/benchmarks/corelib/io/qdir/10000/bench_qdir_10000.cpp
+++ b/tests/benchmarks/corelib/io/qdir/10000/bench_qdir_10000.cpp
@@ -155,6 +155,18 @@ private slots:
}
}
+ void sorted_byTime() {
+ QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
+ testdir.setSorting(QDir::Time);
+ testdir.setFilter(QDir::AllEntries | QDir::System | QDir::Hidden);
+ QBENCHMARK {
+ QStringList fileList = testdir.entryList(QDir::NoFilter, QDir::Time);
+ foreach (const QString &filename, fileList) {
+
+ }
+ }
+ }
+
void sizeSpeedWithoutFilterLowLevel() {
QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
#ifdef Q_OS_WIN