diff --git a/benchmarks/StringEq/StringEq.cpp b/benchmarks/StringEq/StringEq.cpp new file mode 100644 index 000000000..92155f7f7 --- /dev/null +++ b/benchmarks/StringEq/StringEq.cpp @@ -0,0 +1,51 @@ +#include + +using namespace Upp; + +int found; + +void Test(const char *name, const Vector& patterns) +{ + Vector p = clone(patterns); + + Vector data; + for(int i = 0; i < 1000; i++) + data << String(~p[Random(p.GetCount())]); + + while(p.GetCount() < 1000) + p.Append(clone(p)); + + int rfound = 0; + for(int i = 0; i < p.GetCount(); i++) + for(int j = 0; j < data.GetCount(); j++) + if(strcmp(p[i], data[j]) == 0) + rfound++; + + found = 0; + double tm1 = usecs(); + for(int q = 0; q < 1000; q++) + for(int i = 0; i < p.GetCount(); i++) + for(int j = 0; j < data.GetCount(); j++) + if(p[i] == data[j]) + found++; + double tm2 = usecs(); + + if(1000 * rfound != found) + Panic("Failed"); + + RLOG(name << (tm2 - tm1) / p.GetCount() / data.GetCount() << " ns"); +} + +CONSOLE_APP_MAIN +{ + StdLogSetup(LOG_FILE|LOG_COUT); + + SeedRandom(0); + + Test("10 bytes ", { "0123456789", "012345678A" }); + Test("20 bytes ", { "01234567890123456789", "0123456789012345678A" }); + Test("40 bytes ", { "0123456789012345678901234567890123456789", "012345678901234567890123456789012345678A" }); + Test("80 bytes ", { "01234567890123456789012345678901234567890123456789012345678901234567890123456789", + "0123456789012345678901234567890123456789012345678901234567890123456789012345678A", }); + Test("Mixed ", { "01234567890123456789", "0123456789A", "0123456789012345678A2", "012345678901", "012345678901234567890123456789012345678A" }); +} diff --git a/benchmarks/StringEq/StringEq.upp b/benchmarks/StringEq/StringEq.upp new file mode 100644 index 000000000..2b9df1f95 --- /dev/null +++ b/benchmarks/StringEq/StringEq.upp @@ -0,0 +1,10 @@ +uses + Core; + +file + StringEq.cpp, + info.txt; + +mainconfig + "" = ""; + diff --git a/benchmarks/StringEq/info.txt b/benchmarks/StringEq/info.txt new file mode 100644 index 000000000..56b83006d --- /dev/null +++ b/benchmarks/StringEq/info.txt @@ -0,0 +1,57 @@ +OLD +* C:\upp\out\benchmarks\CLANGx64.Debug_Full.Release\StringEq.exe 29.05.2020 17:58:56, user: cxl + +10 bytes 2.6879423828125 ns +20 bytes 7.9278623046875 ns +40 bytes 8.4329384765625 ns +80 bytes 10.6320703125 ns +Mixed 5.1026875 ns + +NEW +* C:\upp\out\benchmarks\CLANGx64.Debug_Full.Release\StringEq.exe 29.05.2020 17:57:23, user: cxl + +10 bytes 2.398326171875 ns +20 bytes 7.5932763671875 ns +40 bytes 8.0952783203125 ns +80 bytes 8.6923046875 ns +Mixed 3.36159609375 ns + +LEq, int64 compare +10 bytes 2.183017578125 ns +20 bytes 7.1306259765625 ns +40 bytes 7.6494228515625 ns +80 bytes 8.2265615234375 ns +Mixed 4.9046890625 ns + +==================== +OLD +* C:\upp\out\benchmarks\MSBT19.Debug_Full.Release\StringEq.exe 29.05.2020 18:01:07, user: cxl + +10 bytes 3.3761689453125 ns +20 bytes 8.996029296875 ns +40 bytes 10.872193359375 ns +80 bytes 15.7719912109375 ns +Mixed 7.46995703125 ns + +NEW + + + +=================== +10 bytes 1.8552822265625 ns +20 bytes 7.9439384765625 ns +40 bytes 8.4297197265625 ns +80 bytes 9.12219921875 ns +Mixed 5.43371484375 ns + +10 bytes 1.8308798828125 ns +20 bytes 7.4739130859375 ns +40 bytes 8.091583984375 ns +80 bytes 8.5558212890625 ns +Mixed 5.6877921875 ns + +10 bytes 1.8308798828125 ns +20 bytes 7.4739130859375 ns +40 bytes 8.091583984375 ns +80 bytes 8.5558212890625 ns +Mixed 5.6877921875 ns diff --git a/benchmarks/VectorInt/VectorInt.cpp b/benchmarks/VectorInt/VectorInt.cpp new file mode 100644 index 000000000..d62ecc99c --- /dev/null +++ b/benchmarks/VectorInt/VectorInt.cpp @@ -0,0 +1,16 @@ +#include + +using namespace Upp; + +#define N 1000000 +#define SZ 100 + +CONSOLE_APP_MAIN +{ + RTIMING("Time"); + for(int i = 0; i < N; i++) { + Vector v; + for(int n = 0; n < SZ; n++) + v.Add(n); + } +} diff --git a/benchmarks/VectorInt/VectorInt.upp b/benchmarks/VectorInt/VectorInt.upp new file mode 100644 index 000000000..9c66885a0 --- /dev/null +++ b/benchmarks/VectorInt/VectorInt.upp @@ -0,0 +1,9 @@ +uses + Core; + +file + VectorInt.cpp; + +mainconfig + "" = ""; + diff --git a/benchmarks/idmapBench/idmapBench.upp b/benchmarks/idmapBench/idmapBench.upp index b988d99f0..a8fa2ead0 100644 --- a/benchmarks/idmapBench/idmapBench.upp +++ b/benchmarks/idmapBench/idmapBench.upp @@ -4,6 +4,7 @@ uses Core; file + info.txt, main.cpp; mainconfig diff --git a/benchmarks/idmapBench/info.txt b/benchmarks/idmapBench/info.txt new file mode 100644 index 000000000..c72840b27 --- /dev/null +++ b/benchmarks/idmapBench/info.txt @@ -0,0 +1,2 @@ +OLD: VectorMap time: 5742398 ms +NEW: VectorMap time: 5888610 ms diff --git a/benchmarks/idmapBench/main.cpp b/benchmarks/idmapBench/main.cpp index d3b93eab7..6b04a97fb 100644 --- a/benchmarks/idmapBench/main.cpp +++ b/benchmarks/idmapBench/main.cpp @@ -328,13 +328,17 @@ CONSOLE_APP_MAIN fn = argv[0]; LoadFile(fn); // cache the file + BenchNTL(fn); // alloc memory #ifdef UPP_HEAP MemoryProfile f; // RLOG(f); // allocated_bytes0 = GetAllocatedBytes(f); + #endif + +#if 0 { TimeStop tm; for(int n = 0; n < N; n++) @@ -361,6 +365,7 @@ CONSOLE_APP_MAIN BenchSortedVectorMap(fn); RLOG("SortedVectorMap time: " << tm.Elapsed() << " ms"); } +#endif { TimeStop tm; for(int n = 0; n < N; n++)