Update /ok to serve dual health check/benchmarking role
This commit is contained in:
34
benchmarks/bench_cpu_work.cpp
Normal file
34
benchmarks/bench_cpu_work.cpp
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user