]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/benchmarks/strings.cpp
Allow small widths if setting initial strings.
[wxWidgets.git] / tests / benchmarks / strings.cpp
index e86b629e96ba2a13876106d7d6f1742ea0ff4dfe..e8506c91f97aba7c222aac146b5699db3f83e29a 100644 (file)
@@ -222,3 +222,39 @@ BENCHMARK_FUNC(ForStringRIter)
     return true;
 }
 
+// ----------------------------------------------------------------------------
+// wxString::Replace()
+// ----------------------------------------------------------------------------
+
+const size_t REPLACE_STR_LEN = strlen(asciistr);
+
+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(ReplaceNone)
+{
+    wxString str('x', REPLACE_STR_LEN);
+    return str.Replace("a", "z") == 0;
+}
+
+BENCHMARK_FUNC(ReplaceSome)
+{
+    wxString str(asciistr);
+    return str.Replace("7", "8") != 0;
+}
+
+BENCHMARK_FUNC(ReplaceAll)
+{
+    wxString str('x', REPLACE_STR_LEN);
+    return str.Replace("x", "y") != 0;
+}
+