blob: f28545fa08d23f96f983721e0d8fbadf3cb2e3b6 (
plain) (
blame)
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
|
#include "bench_window.hpp"
#include "main.hpp"
std::vector<lib94::warrior *> warriors;
std::chrono::nanoseconds time_between_steps;
std::mutex core_mutex;
int main(int argc, char **argv) {
lib94::seed_prng(time(0));
auto app = Gtk::Application::create("net.benjidial.lib94.bench");
return app->make_window_and_run<bench_window>(argc, argv);
}
std::string ns_to_string(std::chrono::nanoseconds dur) {
if (dur.count() >= 10000000000)
return std::to_string((dur.count() + 500000000) / 1000000000) + "s";
if (dur.count() >= 10000000)
return std::to_string((dur.count() + 500000) / 1000000) + "ms";
if (dur.count() >= 10000)
return std::to_string((dur.count() + 500) / 1000) + "μs";
return std::to_string(dur.count()) + "ns";
}
std::string hz_to_string(double rate) {
if (rate >= 10000000.0)
return std::to_string((int)std::round(rate / 1000000.0)) + "MHz";
if (rate >= 10000.0)
return std::to_string((int)std::round(rate / 1000.0)) + "kHz";
if (rate >= 10.0)
return std::to_string((int)std::round(rate)) + "Hz";
return std::to_string((int)std::round(rate * 1000.0)) + "mHz";
}
|