wxWidgets/tests/benchmarks/mbconv.cpp
Vadim Zeitlin 3f66f6a5b3 Remove all lines containing cvs/svn "$Id$" keyword.
This keyword is not expanded by Git which means it's not replaced with the
correct revision value in the releases made using git-based scripts and it's
confusing to have lines with unexpanded "$Id$" in the released files. As
expanding them with Git is not that simple (it could be done with git archive
and export-subst attribute) and there are not many benefits in having them in
the first place, just remove all these lines.

If nothing else, this will make an eventual transition to Git simpler.

Closes #14487.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74602 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-07-26 16:02:46 +00:00

79 lines
2.1 KiB
C++

/////////////////////////////////////////////////////////////////////////////
// Name: tests/benchmarks/mbconv.cpp
// Purpose: MB<->WC conversion benchmarks
// Author: Vadim Zeitlin
// Created: 2008-10-17
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/strconv.h"
#include "wx/string.h"
#include "bench.h"
namespace
{
const wchar_t *TEST_STRING =
L"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod"
L"tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim"
L"veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea"
L"commodo consequat. Duis aute irure dolor in reprehenderit in voluptate"
L"velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint"
L"occaecat cupidatat non proident, sunt in culpa qui officia deserunt"
L"mollit anim id est laborum."
;
// just compute the length of the resulting multibyte string
bool ComputeMBLength(const wxMBConv& conv)
{
// we suppose a fixed length encoding here (which happens to cover UTF-8
// too as long as the test string is ASCII)
return conv.FromWChar(NULL, 0, TEST_STRING)
== (wcslen(TEST_STRING) + 1)*conv.GetMBNulLen();
}
// perform the conversion
bool ConvertToMB(const wxMBConv& conv)
{
const size_t outlen = (wcslen(TEST_STRING) + 1)*conv.GetMBNulLen();
wxCharBuffer buf(outlen - 1); // it adds 1 internally
return conv.FromWChar(buf.data(), outlen, TEST_STRING) == outlen;
}
} // anonymous namespace
BENCHMARK_FUNC(UTF16InitWX)
{
wxMBConvUTF16 conv;
return true;
}
BENCHMARK_FUNC(UTF16InitSys)
{
wxCSConv conv("UTF-16LE");
return conv.IsOk();
}
BENCHMARK_FUNC(UTF16LenWX)
{
return ComputeMBLength(wxMBConvUTF16());
}
BENCHMARK_FUNC(UTF16LenSys)
{
return ComputeMBLength(wxCSConv("UTF-16LE"));
}
BENCHMARK_FUNC(UTF16WX)
{
return ConvertToMB(wxMBConvUTF16());
}
BENCHMARK_FUNC(UTF16Sys)
{
return ConvertToMB(wxCSConv("UTF-16LE"));
}