chore: Make Calibration type a non singleton

This commit is contained in:
TimothyBanks
2026-09-03 12:08:40 -04:00
parent 422b8d0a43
commit 491b930ebb
2 changed files with 4 additions and 16 deletions

View File

@@ -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;

View File

@@ -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_{};
};