54 lines
1.6 KiB
C++
54 lines
1.6 KiB
C++
#include "evo/simulation/world.hpp"
|
|
|
|
#include <chrono>
|
|
#include <exception>
|
|
#include <iostream>
|
|
|
|
int main() try {
|
|
try {
|
|
constexpr std::uint64_t seed = 123456;
|
|
constexpr std::uint32_t count = 10'000;
|
|
constexpr std::uint64_t ticks = 1'000;
|
|
evo::SimulationWorld world{seed};
|
|
for (std::uint32_t index = 0; index < count; ++index) {
|
|
if (!world.create_entity()) {
|
|
return 1;
|
|
}
|
|
}
|
|
const auto start = std::chrono::steady_clock::now();
|
|
for (std::uint64_t tick = 0; tick < ticks; ++tick) {
|
|
if (!world.tick()) {
|
|
return 1;
|
|
}
|
|
}
|
|
const auto elapsed =
|
|
std::chrono::duration<double>(std::chrono::steady_clock::now() - start);
|
|
std::cout << "{\"benchmark\":\"synthetic_tick\",\"seed\":" << seed
|
|
<< ",\"entities\":" << count << ",\"ticks\":" << ticks
|
|
<< ",\"seconds\":" << elapsed.count() << ",\"state_hash\":\"" << std::hex
|
|
<< world.state_hash() << std::dec << "\",\"compiler\":\""
|
|
#if defined(__clang__)
|
|
<< "Clang " << __clang_version__
|
|
#elif defined(_MSC_VER)
|
|
<< "MSVC " << _MSC_VER
|
|
#elif defined(__GNUC__)
|
|
<< "GCC " << __VERSION__
|
|
#else
|
|
<< "unknown"
|
|
#endif
|
|
<< "\",\"build\":\""
|
|
#if defined(NDEBUG)
|
|
<< "release"
|
|
#else
|
|
<< "debug"
|
|
#endif
|
|
<< "\"}\n";
|
|
return 0;
|
|
} catch (const std::exception& error) {
|
|
std::cerr << error.what() << '\n';
|
|
return 1;
|
|
}
|
|
} catch (...) {
|
|
return 1;
|
|
}
|