mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
Merge 4ebe2f6e75 into merged_master (Bitcoin PR #18011)
This commit is contained in:
commit
0f9a38732c
38 changed files with 3656 additions and 586 deletions
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
// Microbenchmark for verification of a basic P2WPKH script. Can be easily
|
||||
// modified to measure performance of other types of scripts.
|
||||
static void VerifyScriptBench(benchmark::State& state)
|
||||
static void VerifyScriptBench(benchmark::Bench& bench)
|
||||
{
|
||||
const ECCVerifyHandle verify_handle;
|
||||
ECC_Start();
|
||||
|
|
@ -50,7 +50,7 @@ static void VerifyScriptBench(benchmark::State& state)
|
|||
witness.stack.push_back(ToByteVector(pubkey));
|
||||
|
||||
// Benchmark.
|
||||
while (state.KeepRunning()) {
|
||||
bench.run([&] {
|
||||
ScriptError err;
|
||||
bool success = VerifyScript(
|
||||
txSpend.vin[0].scriptSig,
|
||||
|
|
@ -74,11 +74,12 @@ static void VerifyScriptBench(benchmark::State& state)
|
|||
(const unsigned char*)stream.data(), stream.size(), 0, flags, nullptr);
|
||||
assert(csuccess == 1);
|
||||
#endif
|
||||
}
|
||||
});
|
||||
ECC_Stop();
|
||||
}
|
||||
|
||||
static void VerifyNestedIfScript(benchmark::State& state) {
|
||||
static void VerifyNestedIfScript(benchmark::Bench& bench)
|
||||
{
|
||||
std::vector<std::vector<unsigned char>> stack;
|
||||
CScript script;
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
|
|
@ -90,15 +91,13 @@ static void VerifyNestedIfScript(benchmark::State& state) {
|
|||
for (int i = 0; i < 100; ++i) {
|
||||
script << OP_ENDIF;
|
||||
}
|
||||
while (state.KeepRunning()) {
|
||||
bench.run([&] {
|
||||
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);
|
||||
BENCHMARK(VerifyScriptBench);
|
||||
BENCHMARK(VerifyNestedIfScript);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue