HomePhabricator

Merge #13419: [tests] Speed up knapsack_solver_test by not recreating wallet…

Description

Merge #13419: [tests] Speed up knapsack_solver_test by not recreating wallet 100 times.

Summary:
a679109be40491222c458fdbef58f68509dae0bd Speed up knapsack_solver_test by not recreating wallet 100 times. (lucash.dev@gmail.com)

Pull request description:

Optimization of `knapsack_solver_test`by moving an expensive wallet creation to outside a 100x for loop.

On my (slow) machine:

```
before:        9.8s
after:         6.2s
--------------------
saved:         3.6s (36%)
```

This PR was split from #13050. Also see #10026.

Tree-SHA512: bde1a856b5f076a5845e14d1a924855c8c91742c3139b47903081289b21d01fef6f2d1fd8947058728a57de56f877bab3866af8cd1d25ba2daa44411752cdb2f

Backport of Core PR13419
https://github.com/bitcoin/bitcoin/pull/13419/

Review note: Easier to see changes if you hide white space changes (https://github.com/bitcoin/bitcoin/pull/13419/files?utf8=%E2%9C%93&diff=split&w=1)

Test Plan:

make check
time(./test_bitcoin --run_test=coinselector_tests/knapsack_solver_test)

Pre-patch:

real    0m4.841s
user    0m4.764s
sys     0m0.076s

Post-patch:

real    0m2.340s
user    0m2.328s
sys     0m0.008s

Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Reviewed By: Fabien, O1 Bitcoin ABC, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D4760