]> git.saurik.com Git - wxWidgets.git/commitdiff
added some Replace() benchmarks (#9802)
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 30 Jul 2008 13:56:17 +0000 (13:56 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 30 Jul 2008 13:56:17 +0000 (13:56 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54844 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

tests/benchmarks/strings.cpp

index e86b629e96ba2a13876106d7d6f1742ea0ff4dfe..321a860f4aea51c3e26cc8497e50aae9b2eedfc9 100644 (file)
@@ -222,3 +222,37 @@ BENCHMARK_FUNC(ForStringRIter)
     return true;
 }
 
+// ----------------------------------------------------------------------------
+// wxString::Replace()
+// ----------------------------------------------------------------------------
+
+const size_t REPLACE_STR_LEN = 1000;
+
+BENCHMARK_FUNC(ReplaceLoop)
+{
+    wxString str('x', REPLACE_STR_LEN);
+    for ( size_t n = 0; n < REPLACE_STR_LEN; n++ )
+    {
+        if ( str[n] == 'a' )
+            str[n] = 'z';
+    }
+
+    return str.length() != 0;
+}
+
+BENCHMARK_FUNC(ReplaceMiss)
+{
+    wxString str('x', REPLACE_STR_LEN);
+    str.Replace("a", "z");
+
+    return str.length() != 0;
+}
+
+BENCHMARK_FUNC(ReplaceHit)
+{
+    wxString str('x', REPLACE_STR_LEN);
+    str.Replace("x", "y");
+
+    return str.length() != 0;
+}
+