mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-25 06:12:47 -06:00
.benchmarks
git-svn-id: svn://ultimatepp.org/upp/trunk@10439 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
23d1fa575c
commit
54cc76eaed
5 changed files with 97 additions and 0 deletions
23
benchmarks/CoFindAll/CoFindAll.cpp
Normal file
23
benchmarks/CoFindAll/CoFindAll.cpp
Normal 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");
|
||||
}
|
||||
9
benchmarks/CoFindAll/CoFindAll.upp
Normal file
9
benchmarks/CoFindAll/CoFindAll.upp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
uses
|
||||
Core;
|
||||
|
||||
file
|
||||
CoFindAll.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "MT";
|
||||
|
||||
52
benchmarks/benchEvent/benchEvent.cpp
Normal file
52
benchmarks/benchEvent/benchEvent.cpp
Normal 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();
|
||||
}
|
||||
9
benchmarks/benchEvent/benchEvent.upp
Normal file
9
benchmarks/benchEvent/benchEvent.upp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
uses
|
||||
Core;
|
||||
|
||||
file
|
||||
benchEvent.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "MT";
|
||||
|
||||
4
benchmarks/benchEvent/init
Normal file
4
benchmarks/benchEvent/init
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#ifndef _benchEvent_icpp_init_stub
|
||||
#define _benchEvent_icpp_init_stub
|
||||
#include "Core/init"
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue