Use plain arrays and atomic read with intrinsics for render

This commit is contained in:
2025-08-29 15:10:10 -04:00
parent 4fc277393e
commit 91e799aae8
2 changed files with 89 additions and 34 deletions

View File

@@ -34,9 +34,12 @@ struct ContentionEnvironment {
: counter_family(
metric::create_counter("bench_counter", "Benchmark counter")),
gauge_family(metric::create_gauge("bench_gauge", "Benchmark gauge")),
histogram_family(metric::create_histogram(
"bench_histogram", "Benchmark histogram",
std::initializer_list<double>{0.1, 0.5, 1.0, 2.5, 5.0})),
histogram_family(
metric::create_histogram("bench_histogram", "Benchmark histogram",
// 7 explicit buckets + automatic +Inf = 8
// total (optimal for SIMD: 2x4 buckets)
std::initializer_list<double>{
0.1, 0.5, 1.0, 2.5, 5.0, 10.0, 25.0})),
counter(counter_family.create({{"benchmark", "contention"}})),
gauge(gauge_family.create({{"benchmark", "contention"}})),
histogram(histogram_family.create({{"benchmark", "contention"}})) {}
@@ -133,9 +136,9 @@ int main() {
ankerl::nanobench::doNotOptimizeAway(gauge);
});
auto histogram_family =
metric::create_histogram("baseline_histogram", "Baseline histogram",
std::initializer_list<double>{0.1, 0.5, 1.0});
auto histogram_family = metric::create_histogram(
"baseline_histogram", "Baseline histogram",
std::initializer_list<double>{0.1, 0.5, 1.0, 2.5, 5.0, 10.0, 25.0});
auto histogram = histogram_family.create({{"type", "baseline"}});
bench.run("histogram.observe() - no contention", [&]() {
@@ -244,9 +247,9 @@ int main() {
auto counter_family =
metric::create_counter("scale_counter", "Scale counter");
auto gauge_family = metric::create_gauge("scale_gauge", "Scale gauge");
auto histogram_family =
metric::create_histogram("scale_histogram", "Scale histogram",
std::initializer_list<double>{0.1, 0.5, 1.0});
auto histogram_family = metric::create_histogram(
"scale_histogram", "Scale histogram",
std::initializer_list<double>{0.1, 0.5, 1.0, 2.5, 5.0, 10.0, 25.0});
// Create varying numbers of metrics
for (int scale : {10, 100, 1000}) {