diff --git a/bench/index.js b/bench/index.js index 1bf5a81..50b7e84 100644 --- a/bench/index.js +++ b/bench/index.js @@ -1,3 +1,4 @@ +const {argv} = require('yargs'); const prettyMs = require('pretty-ms'); const Vain = require('..'); @@ -5,6 +6,22 @@ const isCI = process.env.CI; const xpub = 'xpub6EDZZg3os4RaLxfPpnGBb7ajm6ccyjRs3PGZ5jNK31rPnbpyKb7dc87cEPaLEjFYDBGCQT8VMm8q8MVj2tj7HPBu8syxu82cdHLCNaQmT42'; +// Filter benchmark tests with arguments like: +// $ npm run bench +// $ npm run bench -- --key-format=wif +// $ npm run bench -- --address-format=p2pkh +// $ npm run bench -- --key-format=wif --address-format=p2pkh +const filterOptionsFromArgs = options => { + if ( + (argv.keyFormat && argv.keyFormat !== options.keyFormat) || + (argv.addressFormat && argv.addressFormat !== options.addressFormat) + ) { + return false; + } + + return true; +}; + const options = [ { keyFormat: 'wif', @@ -65,7 +82,7 @@ const options = [ m: 2, prefix: 'BTC' } -]; +].filter(filterOptionsFromArgs); options.forEach(options => { console.log(); diff --git a/package.json b/package.json index 01dda4e..bb0fc98 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "dependencies": { "bip39": "^3.0.2", "bitcoinjs-lib": "^5.0.3", - "tiny-emitter": "^2.1.0" + "tiny-emitter": "^2.1.0", + "yargs": "^14.2.0" } }