@@ -141,6 +141,51 @@ BENCHMARK_TEMPLATE(ecmul, evmone::state::ecmul_execute);
141
141
BENCHMARK_TEMPLATE (ecmul, evmone::state::silkpre_ecmul_execute);
142
142
#endif
143
143
144
+
145
+ template <ExecuteFn Fn>
146
+ void ecpairing (benchmark::State& state)
147
+ {
148
+ const auto input = evmc::from_hex (
149
+ " 105456a333e6d636854f987ea7bb713dfd0ae8371a72aea313ae0c32c0bf10160cf031d41b41557f3e7e3ba0c5"
150
+ " 1bebe5da8e6ecd855ec50fc87efcdeac168bcc0476be093a6d2b4bbf907172049874af11e1b6267606e00804d3"
151
+ " ff0037ec57fd3010c68cb50161b7d1d96bb71edfec9880171954e56871abf3d93cc94d745fa114c059d74e5b6c"
152
+ " 4ec14ae5864ebe23a71781d86c29fb8fb6cce94f70d3de7a2101b33461f39d9e887dbb100f170a2345dde3c07e"
153
+ " 256d1dfa2b657ba5cd030427000000000000000000000000000000000000000000000000000000000000000100"
154
+ " 000000000000000000000000000000000000000000000000000000000000021a2c3013d2ea92e13c800cde68ef"
155
+ " 56a294b883f6ac35d25f587c09b1b3c635f7290158a80cd3d66530f74dc94c94adb88f5cdb481acca997b6e600"
156
+ " 71f08a115f2f997f3dbd66a7afe07fe7862ce239edba9e05c5afff7f8a1259c9733b2dfbb929d1691530ca701b"
157
+ " 4a106054688728c9972c8512e9789e9567aae23e302ccd75000000000000000000000000000000000000000000"
158
+ " 000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000"
159
+ " 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
160
+ " 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
161
+ " 000000000000000000000000000000000000000000000000000000000000000000000000" )
162
+ .value ();
163
+ uint8_t output[32 ];
164
+
165
+ const auto [gas_cost, max_output_size] =
166
+ evmone::state::ecpairing_analyze (input, EVMC_LATEST_STABLE_REVISION);
167
+ if (max_output_size > std::size (output))
168
+ return state.SkipWithError (" too small output" );
169
+
170
+ int64_t total_gas_used = 0 ;
171
+ for ([[maybe_unused]] auto _ : state)
172
+ {
173
+ const auto [status, _2] = Fn (input.data (), input.size (), output, std::size (output));
174
+ if (status != EVMC_SUCCESS) [[unlikely]]
175
+ return state.SkipWithError (" invalid result" );
176
+ total_gas_used += gas_cost;
177
+ }
178
+
179
+ using benchmark::Counter;
180
+ state.counters [" gas_used" ] = Counter (static_cast <double >(gas_cost));
181
+ state.counters [" gas_rate" ] = Counter (static_cast <double >(total_gas_used), Counter::kIsRate );
182
+ }
183
+
184
+ BENCHMARK_TEMPLATE (ecpairing, evmone::state::ecpairing_execute);
185
+ #ifdef EVMONE_PRECOMPILES_SILKPRE
186
+ BENCHMARK_TEMPLATE (ecpairing, evmone::state::silkpre_ecpairing_execute);
187
+ #endif
188
+
144
189
} // namespace
145
190
146
191
BENCHMARK_MAIN ();
0 commit comments