added some Replace() benchmarks (#9802)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54844 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2008-07-30 13:56:17 +00:00
parent 1aec1f8b5e
commit 9729777e2a

View 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;
}