Update /ok to serve dual health check/benchmarking role

This commit is contained in:
2025-09-05 12:39:10 -04:00
parent 761eaa552b
commit e67e4aee17
15 changed files with 265 additions and 53 deletions

View File

@@ -0,0 +1,34 @@
#include <iostream>
#include <nanobench.h>
#include <string>
#include "../src/cpu_work.hpp"
int main(int argc, char *argv[]) {
int iterations = DEFAULT_HEALTH_CHECK_ITERATIONS; // Default: 7000
if (argc > 1) {
try {
iterations = std::stoi(argv[1]);
if (iterations < 0) {
std::cerr << "Error: iterations must be non-negative" << std::endl;
return 1;
}
} catch (const std::exception &e) {
std::cerr << "Error: invalid number '" << argv[1] << "'" << std::endl;
return 1;
}
}
std::cout << "Benchmarking spend_cpu_cycles with " << iterations
<< " iterations" << std::endl;
ankerl::nanobench::Bench bench;
bench.minEpochIterations(10000);
// Benchmark the same CPU work that health checks use
bench.run("spend_cpu_cycles(" + std::to_string(iterations) + ")",
[&] { spend_cpu_cycles(iterations); });
return 0;
}

View File

@@ -1,14 +0,0 @@
#include <nanobench.h>
#include "../src/loop_iterations.hpp"
int main() {
ankerl::nanobench::Bench bench;
bench.minEpochIterations(100000);
bench.run("volatile loop to " + std::to_string(loop_iterations), [&] {
for (volatile int i = 0; i < loop_iterations; i = i + 1)
;
});
return 0;
}