Bug 1395527 part 1 - Add microbenchmarks for IsASCII and IsUTF8. r=froydnj
☠☠ backed out by e990298e1596 ☠ ☠
authorHenri Sivonen <hsivonen@hsivonen.fi>
Thu, 31 Aug 2017 14:46:25 +0300
changeset 427931 40934888ed06465982350390750128f1dbdc831b
parent 427930 7c4c81a8b6996831b41b7a4865a7d7d04188887a
child 427932 d59b62713c66023954833e89374c5ecc2b92df72
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1395527
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1395527 part 1 - Add microbenchmarks for IsASCII and IsUTF8. r=froydnj MozReview-Commit-ID: 3oploVISQ3F
xpcom/tests/gtest/TestStrings.cpp
--- a/xpcom/tests/gtest/TestStrings.cpp
+++ b/xpcom/tests/gtest/TestStrings.cpp
@@ -1350,9 +1350,74 @@ MOZ_GTEST_BENCH(Strings, PerfStripCharsC
       test1.StripChars("\r\n");
       test2.StripChars("\r\n");
       test3.StripChars("\r\n");
       test4.StripChars("\r\n");
       test5.StripChars("\r\n");
     }
 });
 
+// Setup overhead test
+#define OneASCII "a"
+
+// Maximal non-SIMD legth
+#define FifteenASCII "Lorem ipsum dol"
+
+// Around hundred is common length for IsUTF8 check
+#define HundredASCII "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis ac tellus eget velit viverra viverra i"
+
+MOZ_GTEST_BENCH(Strings, PerfIsUTF8One, [] {
+    nsCString test(OneASCII);
+    for (int i = 0; i < 200000; i++) {
+      IsUTF8(test);
+    }
+});
+
+MOZ_GTEST_BENCH(Strings, PerfIsUTF8Fifteen, [] {
+    nsCString test(FifteenASCII);
+    for (int i = 0; i < 200000; i++) {
+      IsUTF8(test);
+    }
+});
+
+MOZ_GTEST_BENCH(Strings, PerfIsUTF8Hundred, [] {
+    nsCString test(HundredASCII);
+    for (int i = 0; i < 200000; i++) {
+      IsUTF8(test);
+    }
+});
+
+MOZ_GTEST_BENCH(Strings, PerfIsUTF8Example3, [] {
+    nsCString test(TestExample3);
+    for (int i = 0; i < 100000; i++) {
+      IsUTF8(test);
+    }
+});
+
+MOZ_GTEST_BENCH(Strings, PerfIsASCII8One, [] {
+    nsCString test(OneASCII);
+    for (int i = 0; i < 200000; i++) {
+      IsASCII(test);
+    }
+});
+
+MOZ_GTEST_BENCH(Strings, PerfIsASCIIFifteen, [] {
+    nsCString test(FifteenASCII);
+    for (int i = 0; i < 200000; i++) {
+      IsASCII(test);
+    }
+});
+
+MOZ_GTEST_BENCH(Strings, PerfIsASCIIHundred, [] {
+    nsCString test(HundredASCII);
+    for (int i = 0; i < 200000; i++) {
+      IsASCII(test);
+    }
+});
+
+MOZ_GTEST_BENCH(Strings, PerfIsASCIIExample3, [] {
+    nsCString test(TestExample3);
+    for (int i = 0; i < 100000; i++) {
+      IsUTF8(test);
+    }
+});
+
 } // namespace TestStrings