-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
47 lines (38 loc) · 1.06 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <UECS/World.h>
using namespace Ubpa::UECS;
#include <chrono>
#include <iostream>
struct A { float val; };
struct B { float val; };
struct TestSystem {
static void OnUpdate(Schedule& schedule) {
schedule.RegisterEntityJob(
[](const A* a, B* b) {
// 256 floating-point operations
for (std::size_t i = 0; i < 256; i++)
b->val *= a->val;
}, "TestSystem");
}
};
int main() {
std::size_t numEntities = 65536;
std::size_t numUpdate = 144 * 10;
World w;
w.systemMngr.RegisterAndActivate<TestSystem>();
auto t0 = std::chrono::steady_clock::now();
for (std::size_t i = 0; i < numEntities; i++)
w.entityMngr.Create<A, B>();
auto t1 = std::chrono::steady_clock::now();
for (std::size_t i = 0; i < numUpdate; i++)
w.Update();
auto t2 = std::chrono::steady_clock::now();
// G5400 : 4 cores
// about 10s
// i5 8400 : 6 cores
// about 6s
auto d0 = t1 - t0;
auto d1 = t2 - t1;
std::cout << "create: " << d0.count() / 1000000000.0 << "s" << std::endl;
std::cout << "update: " << d1.count() / 1000000000.0 << "s" << std::endl;
return 0;
}