.benchmarks

git-svn-id: svn://ultimatepp.org/upp/trunk@10262 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2016-10-04 08:34:25 +00:00
parent 0bf92cb960
commit adf46bd64e
9 changed files with 119 additions and 18 deletions

View file

@ -6,14 +6,13 @@ Atomic val;
struct Data {
int64 val[4];
int xxx;
void Zero() { val[0] = val[1] = val[2] = val[3] = 0; }
};
Data src[16], dst[16];
int count;
#define N 10000000
int count;
@ -32,14 +31,24 @@ force_inline void SSEZero32(void *t)
CONSOLE_APP_MAIN
{
{
RTIMING("Atomic inc/dec");
RTIMING("Atomic Inc+Dec");
for(int i = 0; i < N; i++) {
AtomicInc(val);
AtomicDec(val);
}
}
{
<<<<<<< .mine
RTIMING("Atomic Inc+Dec+test (unstable)");
for(int i = 0; i < N; i++) {
if(i & 1) {
AtomicInc(val);
AtomicInc(val);
}
if(AtomicDec(val))
count++;
}
}
{
RTIMING("Read (no locking)");
for(int i = 0; i < N; i++) {
count += src[i & 15].val[0];
@ -59,19 +68,6 @@ CONSOLE_APP_MAIN
}
}
{
=======
RTIMING("Atomic and test");
for(int i = 0; i < N; i++) {
if(i & 1) {
AtomicInc(val);
AtomicInc(val);
}
if(AtomicDec(val))
count++;
}
}
{
>>>>>>> .r9514
static StaticMutex mtx;
RTIMING("StaticMutex");
for(int i = 0; i < N; i++) {
@ -183,4 +179,11 @@ CONSOLE_APP_MAIN
dst[i & 3] = src[i & 3];
}
}
{
int n = Random();
RTIMING("Divide");
for(int i = 0; i < N; i++) {
dst[i & 15].xxx = src[i & 15].xxx / n;
}
}
}

View file

@ -2,7 +2,10 @@ uses
Core;
file
BenchOps.cpp optimize_speed;
BenchOps.cpp.mine,
BenchOps.cpp.r10063,
BenchOps.cpp.r10157,
BenchOps.cpp;
mainconfig
"" = "MT";

View file

@ -30,6 +30,7 @@ CONSOLE_APP_MAIN
RLOG("CoSort " << tm);
}
#ifdef CPU_64
{
CoWork::SetPoolSize(400);
auto h1 = clone(h);
@ -37,6 +38,7 @@ CONSOLE_APP_MAIN
CoSort(h1);
RLOG("CoSort (big pool) " << tm);
}
#endif
Thread::ShutdownThreads();
RLOG("Exit");

39
benchmarks/LZ4/LZ4.cpp Normal file
View file

@ -0,0 +1,39 @@
#include <Core/Core.h>
#include <plugin/lz4/lz4.h>
using namespace Upp;
CONSOLE_APP_MAIN
{
StdLogSetup(LOG_COUT|LOG_FILE);
TimeStop tm;
String s = LoadFile(GetHomeDirFile("testdata/c12_OCOE_env.blb"));
RLOG("Loaded in " << tm << " s");
s.Cat(s);
RLOG("Original size " << s.GetCount() / 1024 / 1024 << " MB");
{
TimeStop tm;
String c = LZ4Compress(s);
RLOG("Compresss " << s.GetLength() / tm.Seconds() / 1024/1024 << " MB / s");
RLOG("Compressed size " << c.GetCount() / 1024 / 1024 << " MB (" << (100.0 * c.GetCount() / s.GetCount()) << "%)");
tm.Reset();
String d = LZ4Decompress(c);
RLOG("DeCompresss " << s.GetLength() / tm.Seconds() / 1024/1024 << " MB / s");
ASSERT(s == d);
}
{
TimeStop tm;
String c = CoLZ4Compress(s);
RLOG("CoCompresss " << s.GetLength() / tm.Seconds() / 1024/1024 << " MB / s");
RLOG("Compressed size " << c.GetCount() / 1024 / 1024 << " MB (" << (100.0 * c.GetCount() / s.GetCount()) << "%)");
tm.Reset();
String d = CoLZ4Decompress(c);
RLOG("CoDeCompresss " << s.GetLength() / tm.Seconds() / 1024/1024 << " MB / s");
ASSERT(s == d);
}
}

10
benchmarks/LZ4/LZ4.upp Normal file
View file

@ -0,0 +1,10 @@
uses
Core,
plugin/lz4;
file
LZ4.cpp;
mainconfig
"" = "MT";

5
benchmarks/LZ4/init Normal file
View file

@ -0,0 +1,5 @@
#ifndef _LZ4_icpp_init_stub
#define _LZ4_icpp_init_stub
#include "Core/init"
#include "plugin/lz4/init"
#endif

View file

@ -0,0 +1,25 @@
#include <Core/Core.h>
using namespace Upp;
CONSOLE_APP_MAIN
{
Index<String> n;
Vector<String> v;
for(int i = 0; i < 10000000; i++) {
String s = AsString(Random());
n.Add(s);
v.Add(s);
}
{
RTIMING("Sort");
Sort(v);
}
{
RTIMING("IndexSort");
SortIndex(n);
}
}

View file

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

View file

@ -0,0 +1,5 @@
#ifndef _SortIndex_icpp_init_stub
#define _SortIndex_icpp_init_stub
#include "Core/init"
#include "Geom/Coords/init"
#endif