summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2011-03-18 16:31:28 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2011-03-22 14:51:51 (GMT)
commit3f6c5227861f67bde9d4c925f593dea85004ddb2 (patch)
tree3fc1fb7f5765d7dd5690bf2230604a5c312b5acf /tests
parentc4cd963007b957c247cecb35137b0c814202af0f (diff)
downloadQt-3f6c5227861f67bde9d4c925f593dea85004ddb2.zip
Qt-3f6c5227861f67bde9d4c925f593dea85004ddb2.tar.gz
Qt-3f6c5227861f67bde9d4c925f593dea85004ddb2.tar.bz2
Try to remove the non-determinism by moving the malloc() away
Diffstat (limited to 'tests')
-rw-r--r--tests/benchmarks/corelib/tools/qstring/main.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/tests/benchmarks/corelib/tools/qstring/main.cpp b/tests/benchmarks/corelib/tools/qstring/main.cpp
index 4d2c8fa..2861228 100644
--- a/tests/benchmarks/corelib/tools/qstring/main.cpp
+++ b/tests/benchmarks/corelib/tools/qstring/main.cpp
@@ -1564,9 +1564,9 @@ void tst_QString::fromLatin1Alternatives_data() const
QTest::newRow("sse2-with-prolog-unrolled") << &fromLatin1_sse2_withprolog<&fromLatin1_prolog_unrolled>;
}
-static void fromLatin1Alternatives_internal(FromLatin1Function function, bool doVerify)
+extern StringData fromLatin1Data;
+static void fromLatin1Alternatives_internal(FromLatin1Function function, QString &dst, bool doVerify)
{
- extern StringData fromLatin1Data;
struct Entry
{
int len;
@@ -1579,16 +1579,18 @@ static void fromLatin1Alternatives_internal(FromLatin1Function function, bool do
int len = entries[i].len;
const char *src = fromLatin1Data.charData + entries[i].offset1;
- QString dst(len + 16, QChar('x'));
- (function)(&dst.data()->unicode() + 8, src, len);
+ if (!doVerify) {
+ (function)(&dst.data()->unicode(), src, len);
+ } else {
+ dst.fill(QChar('x'), dst.length());
+
+ (function)(&dst.data()->unicode() + 8, src, len);
- if (doVerify) {
QString zeroes(8, QChar('x'));
- QString final = dst.mid(8);
- final.chop(8);
+ QString final = dst.mid(8, len);
QCOMPARE(final, QString::fromLatin1(src, len));
QCOMPARE(dst.left(8), zeroes);
- QCOMPARE(dst.right(8), zeroes);
+ QCOMPARE(dst.mid(len + 8, 8), zeroes);
}
}
}
@@ -1596,9 +1598,12 @@ static void fromLatin1Alternatives_internal(FromLatin1Function function, bool do
void tst_QString::fromLatin1Alternatives() const
{
QFETCH(FromLatin1Function, function);
- fromLatin1Alternatives_internal(function, true);
+
+ QString dst(fromLatin1Data.maxLength + 16, QChar('x'));
+ fromLatin1Alternatives_internal(function, dst, true);
+
QBENCHMARK {
- fromLatin1Alternatives_internal(function, false);
+ fromLatin1Alternatives_internal(function, dst, false);
}
}