Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions test/internal_benchmarks/evmmax_bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ void evmmax_add(benchmark::State& state)
auto a = Mod / 2;
auto b = Mod / 3;

while (state.KeepRunningBatch(2))
for ([[maybe_unused]] auto _ : state)
{
a = m.add(a, b);
b = m.add(b, a);
}
state.counters["avg_time_per_item"] =
benchmark::Counter(2.0 * static_cast<double>(state.iterations()),
benchmark::Counter::kIsRate | benchmark::Counter::kInvert);
}

template <typename UintT, const UintT& Mod>
Expand All @@ -33,11 +36,14 @@ void evmmax_sub(benchmark::State& state)
auto a = Mod / 2;
auto b = Mod / 3;

while (state.KeepRunningBatch(2))
for ([[maybe_unused]] auto _ : state)
{
a = m.sub(a, b);
b = m.sub(b, a);
}
state.counters["avg_time_per_item"] =
benchmark::Counter(2.0 * static_cast<double>(state.iterations()),
benchmark::Counter::kIsRate | benchmark::Counter::kInvert);
}

template <typename UintT, const UintT& Mod>
Expand All @@ -47,11 +53,14 @@ void evmmax_mul(benchmark::State& state)
auto a = m.to_mont(Mod / 2);
auto b = m.to_mont(Mod / 3);

while (state.KeepRunningBatch(2))
for ([[maybe_unused]] auto _ : state)
{
a = m.mul(a, b);
b = m.mul(b, a);
}
state.counters["avg_time_per_item"] =
benchmark::Counter(2.0 * static_cast<double>(state.iterations()),
benchmark::Counter::kIsRate | benchmark::Counter::kInvert);
}
} // namespace

Expand Down
15 changes: 12 additions & 3 deletions test/internal_benchmarks/find_jumpdest_bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,17 @@ void find_jumpdest_random(benchmark::State& state)
const auto begin = map.data();
benchmark::ClobberMemory();

while (state.KeepRunningBatch(indexes.size()))
for ([[maybe_unused]] auto _ : state)
{
for (auto i : indexes)
{
auto x = Fn(begin, jumpdest_map_size, i);
benchmark::DoNotOptimize(x);
}
}
state.counters["avg_time_per_item"] = benchmark::Counter(
static_cast<double>(indexes.size()) * static_cast<double>(state.iterations()),
benchmark::Counter::kIsRate | benchmark::Counter::kInvert);
}

BENCHMARK_TEMPLATE(find_jumpdest_random, int, linear);
Expand Down Expand Up @@ -269,14 +272,17 @@ void find_jumpdest_split_random(benchmark::State& state)
const auto value = map.value.data();
benchmark::ClobberMemory();

while (state.KeepRunningBatch(indexes.size()))
for ([[maybe_unused]] auto _ : state)
{
for (auto i : indexes)
{
auto x = Fn(key, value, jumpdest_map_size, i);
benchmark::DoNotOptimize(x);
}
}
state.counters["avg_time_per_item"] = benchmark::Counter(
static_cast<double>(indexes.size()) * static_cast<double>(state.iterations()),
benchmark::Counter::kIsRate | benchmark::Counter::kInvert);
}

BENCHMARK_TEMPLATE(find_jumpdest_split, uint16_t, lower_bound) ARGS;
Expand All @@ -294,7 +300,7 @@ void find_jumpdest_hashmap_random(benchmark::State& state)
const auto hashmap = std::unordered_map<T, T>{map.begin(), map.end()};
benchmark::ClobberMemory();

while (state.KeepRunningBatch(indexes.size()))
for ([[maybe_unused]] auto _ : state)
{
for (auto i : indexes)
{
Expand All @@ -303,6 +309,9 @@ void find_jumpdest_hashmap_random(benchmark::State& state)
benchmark::DoNotOptimize(x);
}
}
state.counters["avg_time_per_item"] = benchmark::Counter(
static_cast<double>(indexes.size()) * static_cast<double>(state.iterations()),
benchmark::Counter::kIsRate | benchmark::Counter::kInvert);
}

BENCHMARK_TEMPLATE(find_jumpdest_hashmap_random, int);
Expand Down
5 changes: 4 additions & 1 deletion test/internal_benchmarks/lru_cache_bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void lru_cache_put_empty(benchmark::State& state)
data[i] = static_cast<Key>(i);
benchmark::ClobberMemory();

while (state.KeepRunningBatch(static_cast<benchmark::IterationCount>(capacity)))
for ([[maybe_unused]] auto _ : state)
{
for (const auto& key : data)
{
Expand All @@ -118,6 +118,9 @@ void lru_cache_put_empty(benchmark::State& state)
cache.clear();
state.ResumeTiming();
}
state.counters["avg_time_per_item"] =
benchmark::Counter(static_cast<double>(capacity) * static_cast<double>(state.iterations()),
benchmark::Counter::kIsRate | benchmark::Counter::kInvert);
}
BENCHMARK(lru_cache_put_empty<int, int>)->Arg(5000);
BENCHMARK(lru_cache_put_empty<hash256, std::shared_ptr<char>>)->Arg(5000);
Expand Down
7 changes: 5 additions & 2 deletions test/precompiles_bench/precompiles_bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ void precompile(benchmark::State& state)


int64_t total_gas_used = 0;
while (state.KeepRunningBatch(inputs<Id>.size()))
for ([[maybe_unused]] auto _ : state)
{
for (const auto& input : inputs<Id>)
{
Expand All @@ -228,7 +228,10 @@ void precompile(benchmark::State& state)
}

using benchmark::Counter;
state.counters["gas_used"] = Counter(static_cast<double>(batch_gas_cost));
const auto num_inputs = static_cast<double>(inputs<Id>.size());
state.counters["avg_time_per_input"] = Counter(
num_inputs * static_cast<double>(state.iterations()), Counter::kIsRate | Counter::kInvert);
state.counters["avg_gas_used"] = Counter(static_cast<double>(batch_gas_cost) / num_inputs);
state.counters["gas_rate"] = Counter(static_cast<double>(total_gas_used), Counter::kIsRate);
}

Expand Down