.benchmarks

git-svn-id: svn://ultimatepp.org/upp/trunk@16038 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2021-07-31 09:14:22 +00:00
parent 7139fa88ff
commit f706d69858
5 changed files with 98 additions and 12 deletions

View file

@ -4,18 +4,36 @@ using namespace Upp;
#define LDUMP(x) x
template <class T>
String AsHash(const T& x)
{
Sha1Stream s;
const_cast<T&>(x).Serialize(s);
return s.FinishString();
}
CONSOLE_APP_MAIN
{
Pointf x(1, 2);
DDUMP(AsHash(x));
DDUMP(AsHash(Pointf(1, 2)));
DDUMP(AsHash(Pointf(2, 2)));
String s;
for(int i = 0; i < 1000000; i++)
s.Cat(Random());
for(int i = 0; i < 100; i++) {
{
RTIMING("SHA1");
SHA1String(s);
}
{
RTIMING("SHA256");
SHA256String(s);
}
{
RTIMING("MD5");
MD5String(s);
}
{
RTIMING("xxHash");
xxHash(s);
}
{
RTIMING("Save");
SaveFile("c:/xxx/delete.bin", s);
}
{
RTIMING("Load");
LoadFile("c:/xxx/delete.bin");
}
}
}

33
benchmarks/utf/utf.cpp Normal file
View file

@ -0,0 +1,33 @@
#include <Core/Core.h>
using namespace Upp;
CONSOLE_APP_MAIN
{
Vector<dword> data;
for(int i = 0; i < 20000; i++)
data.Add(Random(100));
String utf8 = ToUtf8(data.begin(), 200000);
WString utf16 = utf8.ToWString();
int n = 0;
const int N = 2000;
for(int q = 0; q < N; q++) {
RTIMING("utf8 -> utf32");
n += ToUtf32(utf8).GetCount();
}
for(int q = 0; q < N; q++) {
RTIMING("utf8 -> utf16");
n += ToUtf16(utf8).GetCount();
}
for(int q = 0; q < N; q++) {
RTIMING("utf32 -> utf8");
n += ToUtf8(data.begin(), 200000).GetCount();
}
for(int q = 0; q < N; q++) {
RTIMING("utf16 -> utf8");
n += utf16.ToString().GetCount();
}
RDUMP(n);
}

9
benchmarks/utf/utf.upp Normal file
View file

@ -0,0 +1,9 @@
uses
Core;
file
utf.cpp;
mainconfig
"" = "";

View file

@ -0,0 +1,17 @@
#include <Core/Core.h>
using namespace Upp;
CONSOLE_APP_MAIN
{
WString x;
for(int i = 0; i < 1000000; i++)
x.Cat(Random(20000));
String utf8 = x.ToString();
for(int i = 0; i < 100; i++) {
RTIMING("conversion");
utf8.ToWString();
}
}

View file

@ -0,0 +1,9 @@
uses
Core;
file
utf8transcoding.cpp;
mainconfig
"" = "";