From 693a286600e601fde05049c0819034ed8f7a71d6 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Tue, 28 Feb 2012 20:49:19 +0100 Subject: Add a test using lots of similar strings. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This attempts to emulate a dictionary usecase of sorts, done in code to avoid bloating the git repository by adding an actual word list. Change-Id: I878bc4af8877ba780ee699932f240c0d9c8ff12c Reviewed-by: João Abecasis --- tests/benchmarks/corelib/tools/qhash/main.cpp | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'tests/benchmarks/corelib/tools') diff --git a/tests/benchmarks/corelib/tools/qhash/main.cpp b/tests/benchmarks/corelib/tools/qhash/main.cpp index 18138cbd47..db33200d43 100644 --- a/tests/benchmarks/corelib/tools/qhash/main.cpp +++ b/tests/benchmarks/corelib/tools/qhash/main.cpp @@ -67,6 +67,8 @@ private: ///////////////////// QHash ///////////////////// +#include + void tst_QHash::data() { QTest::addColumn("items"); @@ -99,6 +101,40 @@ void tst_QHash::data() QTest::newRow("uuids-list") << uuids; } + { + // lots of strings with alphabetical characters, vaguely reminiscent of + // a dictionary. + // + // this programatically generates a series like: + // AAAAAA + // AAAAAB + // AAAAAC + // ... + // AAAAAZ + // AAAABZ + // ... + // AAAAZZ + // AAABZZ + QByteArray id("AAAAAAA"); + static QStringList dict; + + if (dict.isEmpty()) { + for (int i = id.length() - 1; i > 0;) { + dict.append(id); + char c = id.at(i); + id[i] = ++c; + + if (c == 'Z') { + // wrap to next digit + i--; + id[i] = 'A'; + } + } + } + + QTest::newRow("dictionary") << dict; + } + } void tst_QHash::qhash_qt4() -- cgit v1.2.3