Bitcoin ABC  0.24.7
P2P Digital Currency
verify_script.cpp
Go to the documentation of this file.
1 // Copyright (c) 2016-2018 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <bench/bench.h>
6 #include <key.h>
7 #if defined(HAVE_CONSENSUS_LIB)
9 #endif
10 #include <script/interpreter.h>
11 #include <script/script.h>
12 #include <script/script_error.h>
13 #include <script/standard.h>
14 #include <streams.h>
15 #include <test/util/transaction_utils.h>
16 
17 #include <array>
18 
20  std::vector<std::vector<uint8_t>> stack;
21  CScript script;
22  for (int i = 0; i < 100; ++i) {
23  script << OP_1 << OP_IF;
24  }
25  for (int i = 0; i < 1000; ++i) {
26  script << OP_1;
27  }
28  for (int i = 0; i < 100; ++i) {
29  script << OP_ENDIF;
30  }
31  bench.run([&] {
32  auto stack_copy = stack;
33  ScriptExecutionMetrics metrics = {};
35  bool ret = EvalScript(stack_copy, script, 0, BaseSignatureChecker(),
36  metrics, &error);
37  assert(ret);
38  });
39 }
40 
ScriptError
ScriptError
Definition: script_error.h:11
VerifyNestedIfScript
static void VerifyNestedIfScript(benchmark::Bench &bench)
Definition: verify_script.cpp:19
streams.h
interpreter.h
ankerl::nanobench::Bench
Main entry point to nanobench's benchmarking facility.
Definition: nanobench.h:583
BaseSignatureChecker
Definition: interpreter.h:31
EvalScript
bool EvalScript(std::vector< valtype > &stack, const CScript &script, uint32_t flags, const BaseSignatureChecker &checker, ScriptExecutionMetrics &metrics, ScriptError *serror)
Definition: interpreter.cpp:203
bitcoinconsensus.h
ankerl::nanobench::Bench::run
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Definition: nanobench.h:1134
standard.h
CScript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:430
bench.h
BENCHMARK
BENCHMARK(VerifyNestedIfScript)
key.h
script_error.h
OP_IF
@ OP_IF
Definition: script.h:76
script.h
ScriptExecutionMetrics
Struct for holding cumulative results from executing a script or a sequence of scripts.
Definition: script_metrics.h:12
error
bool error(const char *fmt, const Args &... args)
Definition: system.h:48
OP_1
@ OP_1
Definition: script.h:55
OP_ENDIF
@ OP_ENDIF
Definition: script.h:81