mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-16 06:05:58 -06:00
52 lines
826 B
C++
52 lines
826 B
C++
#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();
|
|
}
|