mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
.benchmarks
git-svn-id: svn://ultimatepp.org/upp/trunk@16038 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
7139fa88ff
commit
f706d69858
5 changed files with 98 additions and 12 deletions
|
|
@ -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
33
benchmarks/utf/utf.cpp
Normal 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
9
benchmarks/utf/utf.upp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
uses
|
||||
Core;
|
||||
|
||||
file
|
||||
utf.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "";
|
||||
|
||||
17
benchmarks/utf8transcoding/utf8transcoding.cpp
Normal file
17
benchmarks/utf8transcoding/utf8transcoding.cpp
Normal 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();
|
||||
}
|
||||
}
|
||||
9
benchmarks/utf8transcoding/utf8transcoding.upp
Normal file
9
benchmarks/utf8transcoding/utf8transcoding.upp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
uses
|
||||
Core;
|
||||
|
||||
file
|
||||
utf8transcoding.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "";
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue