summaryrefslogtreecommitdiff
path: root/bench/main.cpp
diff options
context:
space:
mode:
authorBenji Dial <benji@benjidial.net>2023-05-29 16:36:19 -0400
committerBenji Dial <benji@benjidial.net>2023-05-29 16:36:19 -0400
commit97c79ff771d4993e322d0d6c44f265180797b2eb (patch)
tree5513cf25721cf21c06efd913ed2f82b980e3cb24 /bench/main.cpp
parent338549f9cd49fa0f3001826c6605663fa6dd019b (diff)
downloadlib94-97c79ff771d4993e322d0d6c44f265180797b2eb.tar.gz
a whole lot more
Diffstat (limited to 'bench/main.cpp')
-rw-r--r--bench/main.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/bench/main.cpp b/bench/main.cpp
new file mode 100644
index 0000000..9663650
--- /dev/null
+++ b/bench/main.cpp
@@ -0,0 +1,31 @@
+#include "bench_window.hpp"
+#include "main.hpp"
+
+std::vector<lib94::warrior *> warriors;
+std::chrono::milliseconds time_between_steps(50);
+std::mutex core_mutex;
+
+int main(int argc, char **argv) {
+ 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";
+}