Skip to content

Commit

Permalink
Benchmark script verification with 100 nested IFs
Browse files Browse the repository at this point in the history
  • Loading branch information
sipa committed Nov 7, 2019
1 parent 2706162 commit 89fb241
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/bench/verify_script.cpp
Expand Up @@ -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);

0 comments on commit 89fb241

Please sign in to comment.