Skip to content

Commit 7cf8a78

Browse files
committed
proper benchmarks
1 parent bcfdae1 commit 7cf8a78

File tree

1 file changed

+3
-47
lines changed

1 file changed

+3
-47
lines changed

test/precompiles_bench/precompiles_bench.cpp

+3-47
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ constexpr auto analyze<PrecompileId::ecadd> = ecadd_analyze;
3232
template <>
3333
constexpr auto analyze<PrecompileId::ecmul> = ecmul_analyze;
3434
template <>
35-
[[maybe_unused]] constexpr auto analyze<PrecompileId::ecpairing> = ecpairing_analyze;
35+
constexpr auto analyze<PrecompileId::ecpairing> = ecpairing_analyze;
3636

3737
template <PrecompileId>
3838
const inline std::array inputs{0};
@@ -185,57 +185,13 @@ BENCHMARK_TEMPLATE(precompile, PrecompileId::ecmul, libff);
185185

186186
namespace bench_ecpairing
187187
{
188+
constexpr auto evmmax_cpp = ecpairing_execute;
189+
BENCHMARK_TEMPLATE(precompile, PrecompileId::ecpairing, evmmax_cpp);
188190
#ifdef EVMONE_PRECOMPILES_SILKPRE
189191
constexpr auto libff = silkpre_ecpairing_execute;
190192
BENCHMARK_TEMPLATE(precompile, PrecompileId::ecpairing, libff);
191193
#endif
192194
} // namespace bench_ecpairing
193-
194-
195-
template <ExecuteFn Fn>
196-
void ecpairing(benchmark::State& state)
197-
{
198-
const auto input = evmc::from_hex(
199-
"105456a333e6d636854f987ea7bb713dfd0ae8371a72aea313ae0c32c0bf10160cf031d41b41557f3e7e3ba0c5"
200-
"1bebe5da8e6ecd855ec50fc87efcdeac168bcc0476be093a6d2b4bbf907172049874af11e1b6267606e00804d3"
201-
"ff0037ec57fd3010c68cb50161b7d1d96bb71edfec9880171954e56871abf3d93cc94d745fa114c059d74e5b6c"
202-
"4ec14ae5864ebe23a71781d86c29fb8fb6cce94f70d3de7a2101b33461f39d9e887dbb100f170a2345dde3c07e"
203-
"256d1dfa2b657ba5cd030427000000000000000000000000000000000000000000000000000000000000000100"
204-
"000000000000000000000000000000000000000000000000000000000000021a2c3013d2ea92e13c800cde68ef"
205-
"56a294b883f6ac35d25f587c09b1b3c635f7290158a80cd3d66530f74dc94c94adb88f5cdb481acca997b6e600"
206-
"71f08a115f2f997f3dbd66a7afe07fe7862ce239edba9e05c5afff7f8a1259c9733b2dfbb929d1691530ca701b"
207-
"4a106054688728c9972c8512e9789e9567aae23e302ccd75000000000000000000000000000000000000000000"
208-
"000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000"
209-
"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
210-
"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
211-
"000000000000000000000000000000000000000000000000000000000000000000000000")
212-
.value();
213-
uint8_t output[32];
214-
215-
const auto [gas_cost, max_output_size] =
216-
evmone::state::ecpairing_analyze(input, EVMC_LATEST_STABLE_REVISION);
217-
if (max_output_size > std::size(output))
218-
return state.SkipWithError("too small output");
219-
220-
int64_t total_gas_used = 0;
221-
for ([[maybe_unused]] auto _ : state)
222-
{
223-
const auto [status, _2] = Fn(input.data(), input.size(), output, std::size(output));
224-
if (status != EVMC_SUCCESS) [[unlikely]]
225-
return state.SkipWithError("invalid result");
226-
total_gas_used += gas_cost;
227-
}
228-
229-
using benchmark::Counter;
230-
state.counters["gas_used"] = Counter(static_cast<double>(gas_cost));
231-
state.counters["gas_rate"] = Counter(static_cast<double>(total_gas_used), Counter::kIsRate);
232-
}
233-
234-
BENCHMARK_TEMPLATE(ecpairing, evmone::state::ecpairing_execute);
235-
#ifdef EVMONE_PRECOMPILES_SILKPRE
236-
BENCHMARK_TEMPLATE(ecpairing, evmone::state::silkpre_ecpairing_execute);
237-
#endif
238-
239195
} // namespace
240196

241197
BENCHMARK_MAIN();

0 commit comments

Comments
 (0)