6
6
#include " test/utils/utils.hpp"
7
7
#include < benchmark/benchmark.h>
8
8
#include < evmc/evmc.hpp>
9
+ #include < evmc/mocked_host.hpp>
9
10
#include < evmone/analysis.hpp>
10
11
#include < evmone/baseline.hpp>
11
12
@@ -46,23 +47,26 @@ inline void baseline_analyze(benchmark::State& state, bytes_view code) noexcept
46
47
state.counters [" rate" ] = Counter (static_cast <double >(bytes_analysed), Counter::kIsRate );
47
48
}
48
49
49
- inline evmc::result execute (
50
- evmc::VM& vm, evmc_revision rev, int64_t gas_limit, bytes_view code, bytes_view input) noexcept
50
+ inline evmc::result execute (evmc::VM& vm, evmc::Host& host, evmc_revision rev, int64_t gas_limit,
51
+ bytes_view code, bytes_view input) noexcept
51
52
{
52
53
auto msg = evmc_message{};
53
54
msg.gas = gas_limit;
54
55
msg.input_data = input.data ();
55
56
msg.input_size = input.size ();
56
- return vm.execute (rev, msg, code.data (), code.size ());
57
+ return vm.execute (host, rev, msg, code.data (), code.size ());
57
58
}
58
59
59
60
inline void execute (benchmark::State& state, evmc::VM& vm, bytes_view code, bytes_view input = {},
60
61
bytes_view expected_output = {}) noexcept
61
62
{
62
63
constexpr auto rev = default_revision;
63
64
constexpr auto gas_limit = default_gas_limit;
65
+
66
+ evmc::MockedHost host;
67
+
64
68
{ // Test run.
65
- const auto r = execute (vm, rev, gas_limit, code, input);
69
+ const auto r = execute (vm, host, rev, gas_limit, code, input);
66
70
if (r.status_code != EVMC_SUCCESS)
67
71
{
68
72
state.SkipWithError ((" failure: " + std::to_string (r.status_code )).c_str ());
@@ -85,7 +89,7 @@ inline void execute(benchmark::State& state, evmc::VM& vm, bytes_view code, byte
85
89
auto iteration_gas_used = int64_t {0 };
86
90
for (auto _ : state)
87
91
{
88
- auto r = execute (vm, rev, gas_limit, code, input);
92
+ auto r = execute (vm, host, rev, gas_limit, code, input);
89
93
iteration_gas_used = gas_limit - r.gas_left ;
90
94
total_gas_used += iteration_gas_used;
91
95
}
0 commit comments