Bitcoin ABC  0.26.3
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 
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:431
Main entry point to nanobench's benchmarking facility.
Definition: nanobench.h:616
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Definition: nanobench.h:1183
bool EvalScript(std::vector< valtype > &stack, const CScript &script, uint32_t flags, const BaseSignatureChecker &checker, ScriptExecutionMetrics &metrics, ScriptError *serror)
@ OP_IF
Definition: script.h:77
@ OP_ENDIF
Definition: script.h:82
@ OP_1
Definition: script.h:56
ScriptError
Definition: script_error.h:11
Struct for holding cumulative results from executing a script or a sequence of scripts.
bool error(const char *fmt, const Args &...args)
Definition: system.h:46
assert(!tx.IsCoinBase())
BENCHMARK(VerifyNestedIfScript)
static void VerifyNestedIfScript(benchmark::Bench &bench)