From 491b930ebb1f2a70399cab6aec7f95ecfb2f5d31 Mon Sep 17 00:00:00 2001 From: TimothyBanks Date: Thu, 3 Sep 2026 12:08:40 -0400 Subject: [PATCH] chore: Make Calibration type a non singleton --- src/benchmarks/libxrpl/wasm/WasmBench.cpp | 13 +++---------- src/benchmarks/libxrpl/wasm/WasmBench.h | 7 +------ 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/benchmarks/libxrpl/wasm/WasmBench.cpp b/src/benchmarks/libxrpl/wasm/WasmBench.cpp index c0ca253e54..423e1291b9 100644 --- a/src/benchmarks/libxrpl/wasm/WasmBench.cpp +++ b/src/benchmarks/libxrpl/wasm/WasmBench.cpp @@ -195,13 +195,6 @@ Calibration::Calibration() { } -Calibration const& -Calibration::instance() -{ - static Calibration const kValue; - return kValue; -} - double declaredGas(std::string_view wasmName) { @@ -217,10 +210,10 @@ report( std::string_view wasmName, bool throughVm) { - auto const perGas = Calibration::instance().secondsPerGas(); + auto calibration = Calibration{}; + auto const perGas = calibration.secondsPerGas(); auto const implied = perGas > 0.0 ? secondsPerCall / perGas : 0.0; - auto const suggested = - throughVm ? implied : implied + Calibration::instance().crossingFloorGas(); + auto const suggested = throughVm ? implied : implied + calibration.crossingFloorGas(); state.counters["implied_gas"] = implied; state.counters["ns_per_call"] = secondsPerCall * 1e9; diff --git a/src/benchmarks/libxrpl/wasm/WasmBench.h b/src/benchmarks/libxrpl/wasm/WasmBench.h index 6c5762793f..3caa7a02f6 100644 --- a/src/benchmarks/libxrpl/wasm/WasmBench.h +++ b/src/benchmarks/libxrpl/wasm/WasmBench.h @@ -94,10 +94,7 @@ timeRun(HostFunctions& host, Bytes const& wasm); class Calibration { public: - // The machine's calibration, measured on first use. Measuring runs a few hundred short - // contracts, so the first case to ask pays for it and every later case reads this answer. - static Calibration const& - instance(); + Calibration(); // Seconds of wall time one unit of gas buys here. [[nodiscard]] double @@ -115,8 +112,6 @@ public: } private: - Calibration(); - double secondsPerGas_{}; double crossingFloorGas_{}; };