AddToBlock
was called repeatedly from addPackageTxs
where the constant value of printpriority
is recalculated every time.
This showed up during profiling of AssembleBlock, fetching it once in the constructor results in a small speed increase for many iterations.
./src/bench/bench_bitcoin –filter=‘AssembleBlock’ –min-time=10000
before:
ns/op | op/s | err% | total | benchmark |
---|---|---|---|---|
156,460.15 | 6,391.40 | 0.1% | 11.03 | AssembleBlock |
after:
ns/op | op/s | err% | total | benchmark |
---|---|---|---|---|
149,289.55 | 6,698.39 | 0.3% | 10.97 | AssembleBlock |
The slight speedup shows up in CI as well: