summaryrefslogtreecommitdiff
path: root/tests/benchmarks
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-08-12 21:14:00 +0200
committerThiago Macieira <thiago.macieira@nokia.com>2010-08-24 12:36:31 +0200
commitd8ad0812c7fdc2684ce7f09cc13b69f567e82031 (patch)
tree222c8733ad1953a53daea01b9653fa79c22de636 /tests/benchmarks
parentde76f8f32b84409a7053d5d95a3855b8590389e1 (diff)
downloadqt4-tools-d8ad0812c7fdc2684ce7f09cc13b69f567e82031.tar.gz
Add a benchmark for SSE2 comparison.
This function uses unaligned loads. I'll try to write one with aligned loads later.
Diffstat (limited to 'tests/benchmarks')
-rw-r--r--tests/benchmarks/corelib/tools/qstring/main.cpp27
-rw-r--r--tests/benchmarks/corelib/tools/qstring/qstring.pro1
2 files changed, 28 insertions, 0 deletions
diff --git a/tests/benchmarks/corelib/tools/qstring/main.cpp b/tests/benchmarks/corelib/tools/qstring/main.cpp
index 9eb6294f44..521003490f 100644
--- a/tests/benchmarks/corelib/tools/qstring/main.cpp
+++ b/tests/benchmarks/corelib/tools/qstring/main.cpp
@@ -219,6 +219,27 @@ static bool equals2_intwise(ushort *p1, ushort *p2, int length)
return true;
}
+#ifdef __SSE2__
+static bool equals2_sse2(ushort *p1, ushort *p2, int len)
+{
+ if (len > 8) {
+ while (len > 8) {
+ __m128i q1 = _mm_loadu_si128((__m128i *)p1);
+ __m128i q2 = _mm_loadu_si128((__m128i *)p2);
+ __m128i cmp = _mm_cmpeq_epi16(q1, q2);
+ if (ushort(_mm_movemask_epi8(cmp)) != 0xffff)
+ return false;
+
+ len -= 8;
+ p1 += 8;
+ p2 += 8;
+ }
+ }
+
+ return equals2_shortwise(p1, p2, len);
+}
+#endif
+
void tst_QString::equals2_data() const
{
QTest::addColumn<int>("algorithm");
@@ -227,6 +248,9 @@ void tst_QString::equals2_data() const
QTest::newRow("bytewise") << 1;
QTest::newRow("shortwise") << 2;
QTest::newRow("intwise") << 3;
+#ifdef __SSE2__
+ QTest::newRow("sse2") << 4;
+#endif
}
void tst_QString::equals2() const
@@ -274,6 +298,9 @@ void tst_QString::equals2() const
equals2_bytewise, // 1
equals2_shortwise, // 1
equals2_intwise, // 3
+#ifdef __SSE2__
+ equals2_sse2, // 4
+#endif
0
};
diff --git a/tests/benchmarks/corelib/tools/qstring/qstring.pro b/tests/benchmarks/corelib/tools/qstring/qstring.pro
index fa4310e7e3..388e3c26c5 100644
--- a/tests/benchmarks/corelib/tools/qstring/qstring.pro
+++ b/tests/benchmarks/corelib/tools/qstring/qstring.pro
@@ -14,3 +14,4 @@ wince*:{
DEFINES += SRCDIR=\\\"$$PWD/\\\"
}
+sse2:QMAKE_CXXFLAGS += -msse2