]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/benchmarks/strings.cpp
Document lack of wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK under OS X.
[wxWidgets.git] / tests / benchmarks / strings.cpp
index cc09a35418c2d4882c65d4e888f7e7f928060495..6ea1f53e8608bc120fe28d44132a41b89053e909 100644 (file)
@@ -5,7 +5,7 @@
 // Created:     2008-07-19
 // RCS-ID:      $Id$
 // Copyright:   (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
-// Licence:     wxWindows license
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 #include "wx/string.h"
@@ -293,6 +293,114 @@ BENCHMARK_FUNC(ReplaceShorter)
     return str.Replace("xx", "y") != 0;
 }
 
+// ----------------------------------------------------------------------------
+// string case conversion
+// ----------------------------------------------------------------------------
+
+BENCHMARK_FUNC(Lower)
+{
+    return GetTestAsciiString().Lower().length() > 0;
+}
+
+BENCHMARK_FUNC(Upper)
+{
+    return GetTestAsciiString().Upper().length() > 0;
+}
+
+// ----------------------------------------------------------------------------
+// string comparison
+// ----------------------------------------------------------------------------
+
+BENCHMARK_FUNC(StrcmpA)
+{
+    const wxString& s = GetTestAsciiString();
+
+    return wxCRT_StrcmpA(s.c_str(), s.c_str()) == 0;
+}
+
+BENCHMARK_FUNC(StrcmpW)
+{
+    const wxString& s = GetTestAsciiString();
+
+    return wxCRT_StrcmpW(s.wc_str(), s.wc_str()) == 0;
+}
+
+BENCHMARK_FUNC(StricmpA)
+{
+    const wxString& s = GetTestAsciiString();
+
+    return wxCRT_StricmpA(s.c_str(), s.c_str()) == 0;
+}
+
+BENCHMARK_FUNC(StricmpW)
+{
+    const wxString& s = GetTestAsciiString();
+
+    return wxCRT_StricmpW(s.wc_str(), s.wc_str()) == 0;
+}
+
+BENCHMARK_FUNC(StringCmp)
+{
+    const wxString& s = GetTestAsciiString();
+
+    return s.Cmp(s) == 0;
+}
+
+BENCHMARK_FUNC(StringCmpNoCase)
+{
+    const wxString& s = GetTestAsciiString();
+
+    return s.CmpNoCase(s) == 0;
+}
+
+// Also benchmark various native functions under MSW. Surprisingly/annoyingly
+// they sometimes have vastly better performance than alternatives, especially
+// for case-sensitive comparison (see #10375).
+#ifdef __WINDOWS__
+
+#include "wx/msw/wrapwin.h"
+
+BENCHMARK_FUNC(MSWlstrcmp)
+{
+    const wxString& s = GetTestAsciiString();
+
+    return lstrcmp(s.t_str(), s.t_str()) == 0;
+}
+
+BENCHMARK_FUNC(MSWlstrcmpi)
+{
+    const wxString& s = GetTestAsciiString();
+
+    return lstrcmpi(s.t_str(), s.t_str()) == 0;
+}
+
+BENCHMARK_FUNC(MSWCompareString)
+{
+    const wxString& s = GetTestAsciiString();
+
+    return ::CompareString
+             (
+                LOCALE_USER_DEFAULT,
+                0,
+                s.t_str(), s.length(),
+                s.t_str(), s.length()
+             ) == CSTR_EQUAL;
+}
+
+BENCHMARK_FUNC(MSWCompareStringIgnoreCase)
+{
+    const wxString& s = GetTestAsciiString();
+
+    return ::CompareString
+             (
+                LOCALE_USER_DEFAULT,
+                NORM_IGNORECASE,
+                s.t_str(), s.length(),
+                s.t_str(), s.length()
+             ) == CSTR_EQUAL;
+}
+
+#endif // __WINDOWS__
 
 // ----------------------------------------------------------------------------
 // string buffers: wx[W]CharBuffer