.benchmarks

git-svn-id: svn://ultimatepp.org/upp/trunk@10439 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2016-11-15 10:21:27 +00:00
parent 23d1fa575c
commit 54cc76eaed
5 changed files with 97 additions and 0 deletions

View file

@ -0,0 +1,23 @@
#include <Core/Core.h>
using namespace Upp;
CONSOLE_APP_MAIN
{
StdLogSetup(LOG_COUT|LOG_FILE);
Vector<int> data;
for(int i = 0; i < 100000000; i++)
data.Add(Random());
{
RTIMING("FindAll");
RDUMP(FindAll(data, [=](int c) { return c % 177777 == 0; }).GetCount());
}
{
RTIMING("CoFindAll");
RDUMP(CoFindAll(data, [=](int c) { return c % 177777 == 0; }).GetCount());
}
LOG("===================== OK");
}

View file

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

View file

@ -0,0 +1,52 @@
#include <Core/Core.h>
using namespace Upp;
struct Test {
int sum;
Vector<Event<>> cb;
void Method1() {
sum++;
}
void Method2(int d) {
sum += d;
}
typedef Test CLASSNAME;
Test() {
const int N = 1000000;
for(int j = 0; j < 50; j++) {
cb.Clear();
for(int i = 0; i < N; i++) {
RTIMING("Adding Method1");
cb.Add([=] { Method1(); });
}
sum = 0;
for(int i = 0; i < cb.GetCount(); i++) {
RTIMING("Calling Method1");
cb[i]();
}
RDUMP(sum);
cb.Clear();
for(int i = 0; i < N; i++) {
RTIMING("Adding Method2");
cb.Add([=] { Method2(i); });
}
sum = 0;
for(int i = 0; i < cb.GetCount(); i++) {
RTIMING("Calling Method2");
cb[i]();
}
RDUMP(sum);
}
}
};
CONSOLE_APP_MAIN
{
Test();
}

View file

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

View file

@ -0,0 +1,4 @@
#ifndef _benchEvent_icpp_init_stub
#define _benchEvent_icpp_init_stub
#include "Core/init"
#endif