diff options
author | Robin Burchell <robin+qt@viroteck.net> | 2012-02-28 21:04:53 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-29 22:39:00 +0100 |
commit | b147da00c5fec9d89a2b60d10e82ac28766e2a5b (patch) | |
tree | af4de605a25c559e9268de5654e0e4ddd7a668ea /tests/benchmarks/corelib | |
parent | 1f4804452c05c57308979bf090305c7c882f92c9 (diff) |
Remove qhash_faster.
It's not faster under _any_ metric than the new algorithm, and it loses a lot of
spread which is a bad thing.
Change-Id: Ic87258f1c887822ffea1cb1517355564fabc3c26
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Diffstat (limited to 'tests/benchmarks/corelib')
-rw-r--r-- | tests/benchmarks/corelib/tools/qhash/main.cpp | 18 | ||||
-rw-r--r-- | tests/benchmarks/corelib/tools/qhash/main.h | 11 | ||||
-rw-r--r-- | tests/benchmarks/corelib/tools/qhash/outofline.cpp | 44 |
3 files changed, 0 insertions, 73 deletions
diff --git a/tests/benchmarks/corelib/tools/qhash/main.cpp b/tests/benchmarks/corelib/tools/qhash/main.cpp index 62384fbaa7..67396ffd57 100644 --- a/tests/benchmarks/corelib/tools/qhash/main.cpp +++ b/tests/benchmarks/corelib/tools/qhash/main.cpp @@ -57,8 +57,6 @@ private slots: void initTestCase(); void qhash_qt4_data() { data(); } void qhash_qt4(); - void qhash_faster_data() { data(); } - void qhash_faster(); void javaString_data() { data(); } void javaString(); @@ -151,22 +149,6 @@ void tst_QHash::qhash_qt4() } } -void tst_QHash::qhash_faster() -{ - QFETCH(QStringList, items); - QHash<String, int> hash; - - QList<String> realitems; - foreach (const QString &s, items) - realitems.append(s); - - QBENCHMARK { - for (int i = 0, n = realitems.size(); i != n; ++i) { - hash[realitems.at(i)] = i; - } - } -} - void tst_QHash::javaString() { QFETCH(QStringList, items); diff --git a/tests/benchmarks/corelib/tools/qhash/main.h b/tests/benchmarks/corelib/tools/qhash/main.h index 3d193b5e40..a865eaf7a6 100644 --- a/tests/benchmarks/corelib/tools/qhash/main.h +++ b/tests/benchmarks/corelib/tools/qhash/main.h @@ -52,17 +52,6 @@ uint qHash(const Qt4String &); QT_END_NAMESPACE -struct String : QString -{ - String() {} - String(const QString &s) : QString(s) {} -}; - -QT_BEGIN_NAMESPACE -uint qHash(const String &); -QT_END_NAMESPACE - - struct JavaString : QString { JavaString() {} diff --git a/tests/benchmarks/corelib/tools/qhash/outofline.cpp b/tests/benchmarks/corelib/tools/qhash/outofline.cpp index 8adaa0a04f..75d99f96f8 100644 --- a/tests/benchmarks/corelib/tools/qhash/outofline.cpp +++ b/tests/benchmarks/corelib/tools/qhash/outofline.cpp @@ -57,50 +57,6 @@ uint qHash(const Qt4String &str) return h; } -static void doHash(const unsigned short *p, uint &h) -{ -#if 1 - // Copied from static uint hash(const QChar *p, int n). - // Possibly not the cheapest way. - h = (h << 4) + (*p++); - h ^= (h & 0xf0000000) >> 23; - h &= 0x0fffffff; - - h = (h << 4) + (*p++); - h ^= (h & 0xf0000000) >> 23; - h &= 0x0fffffff; - - h = (h << 4) + (*p++); - h ^= (h & 0xf0000000) >> 23; - h &= 0x0fffffff; - - h = (h << 4) + (*p++); - h ^= (h & 0xf0000000) >> 23; - h &= 0x0fffffff; -#else - // Faster, but probably less spread. - h ^= *(unsigned int *)p; -#endif -} - -uint qHash(const String &str) -{ - const unsigned short *p = (unsigned short *)str.constData(); - const int s = str.size(); - switch (s) { - case 0: return 0; - case 1: return *p; - case 2: return *(unsigned int *)p; - case 3: return (*(unsigned int *)p) ^ *(p + 2); - //case 3: return (*p << 11) + (*(p + 1) << 22) + *(p + 2); - } - uint h = 0; - doHash(p, h); - doHash(p + s / 2 - 2, h); - doHash(p + s - 4, h); - return h; -} - // The Java's hashing algorithm for strings is a variation of D. J. Bernstein // hashing algorithm appeared here http://cr.yp.to/cdb/cdb.txt // and informally known as DJB33XX - DJB's 33 Times Xor. |