aboutsummaryrefslogtreecommitdiff
path: root/src/bench/verify_script.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2019-09-17 19:34:51 -0700
committerPieter Wuille <pieter.wuille@gmail.com>2019-11-07 09:12:26 -0800
commit89fb241c54fc85befacfa3703d8e21bf3b8a76eb (patch)
tree3e2e4646b59dc6e0ef2bedf549586c3ef066f340 /src/bench/verify_script.cpp
parent270616228bc9a3856a0a82dea26ac3480b7585cd (diff)
Benchmark script verification with 100 nested IFs
Diffstat (limited to 'src/bench/verify_script.cpp')
-rw-r--r--src/bench/verify_script.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/bench/verify_script.cpp b/src/bench/verify_script.cpp
index 1c025e29d3..5894f22b5b 100644
--- a/src/bench/verify_script.cpp
+++ b/src/bench/verify_script.cpp
@@ -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);