Benchmark script verification with 100 nested IFs

This commit is contained in:
Pieter Wuille 2019-09-17 19:34:51 -07:00
parent 270616228b
commit 89fb241c54

View File

@ -71,4 +71,27 @@ static void VerifyScriptBench(benchmark::State& state)
}
}
static void VerifyNestedIfScript(benchmark::State& state) {
std::vector<std::vector<unsigned char>> stack;
CScript script;
for (int i = 0; i < 100; ++i) {
script << OP_1 << OP_IF;
}
for (int i = 0; i < 1000; ++i) {
script << OP_1;
}
for (int i = 0; i < 100; ++i) {
script << OP_ENDIF;
}
while (state.KeepRunning()) {
auto stack_copy = stack;
ScriptError error;
bool ret = EvalScript(stack_copy, script, 0, BaseSignatureChecker(), SigVersion::BASE, &error);
assert(ret);
}
}
BENCHMARK(VerifyScriptBench, 6300);
BENCHMARK(VerifyNestedIfScript, 100);