.benchmarks

git-svn-id: svn://ultimatepp.org/upp/trunk@9467 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2016-02-11 21:40:00 +00:00
parent a8d510ae98
commit 6f2b785d8d
2 changed files with 108 additions and 0 deletions

View file

@ -0,0 +1,99 @@
#include <Core/Core.h>
using namespace Upp;
Atomic val;
struct Data {
int64 val[4];
};
Data src[16], dst[16];
#define N 100000000
CONSOLE_APP_MAIN
{
{
RTIMING("Atomic");
for(int i = 0; i < N; i++) {
AtomicInc(val);
AtomicDec(val);
}
}
{
static StaticMutex mtx;
RTIMING("StaticMutex");
for(int i = 0; i < N; i++) {
Mutex::Lock __(mtx);
}
}
{
static Mutex mtx;
RTIMING("Mutex");
for(int i = 0; i < N; i++) {
Mutex::Lock __(mtx);
}
}
{
static SpinLock lock;
RTIMING("SpinLock");
for(int i = 0; i < N; i++) {
SpinLock::Lock __(lock);
}
}
{
RTIMING("Alloc/Free");
for(int i = 0; i < N; i++) {
delete[] new byte[32];
}
}
{
RTIMING("Alloc/Free large");
for(int i = 0; i < N; i++) {
delete[] new byte[3000];
}
}
{
RTIMING("malloc/free 32");
for(int i = 0; i < N; i++) {
free(malloc(32));
}
}
{
RTIMING("malloc/free 3000");
for(int i = 0; i < N; i++) {
free(malloc(3000));
}
}
{
RTIMING("Copy32");
for(int i = 0; i < N; i++) {
dst[i & 15] = src[i & 15];
}
}
{
RTIMING("Copy64");
for(int i = 0; i < N; i++) {
dst[i & 15] = src[i & 15];
dst[i & 7] = src[i & 7];
}
}
{
RTIMING("Copy96");
for(int i = 0; i < N; i++) {
dst[i & 15] = src[i & 15];
dst[i & 7] = src[i & 7];
dst[i & 3] = src[i & 3];
}
}
{
RTIMING("Copy128");
for(int i = 0; i < N; i++) {
dst[i & 1] = src[i & 1];
dst[i & 15] = src[i & 15];
dst[i & 7] = src[i & 7];
dst[i & 3] = src[i & 3];
}
}
}

View file

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