Skip to content

Commit

Permalink
Use effective value instead of value
Browse files Browse the repository at this point in the history
  • Loading branch information
yancyribbens committed Feb 2, 2024
1 parent ba3c269 commit bef818e
Show file tree
Hide file tree
Showing 5 changed files with 400 additions and 108 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ keywords = ["crypto", "bitcoin"]
readme = "README.md"

[dependencies]
bitcoin = { git="https://github.com/yancyribbens/rust-bitcoin", branch = "add-effective-value-calculation" }
bitcoin = { git="https://github.com/yancyribbens/rust-bitcoin", branch = "tmp/mark-txin-base-weight-public" }
rand = {version = "0.8.5", default-features = false, optional = true}

[dev-dependencies]
Expand All @@ -24,10 +24,10 @@ rust-bitcoin-coin-selection = {path = ".", features = ["rand"]}
rand = "0.8.5"

[patch.crates-io]
bitcoin_hashes = { git = "https://github.com/yancyribbens/rust-bitcoin", branch = "add-effective-value-calculation" }
bitcoin-io = { git = "https://github.com/yancyribbens/rust-bitcoin", branch = "add-effective-value-calculation" }
bitcoin-units = { git = "https://github.com/yancyribbens/rust-bitcoin", branch = "add-effective-value-calculation" }
bitcoin-internals = { git = "https://github.com/yancyribbens/rust-bitcoin", branch = "add-effective-value-calculation" }
bitcoin_hashes = { git = "https://github.com/yancyribbens/rust-bitcoin", branch = "tmp/mark-txin-base-weight-public" }
bitcoin-io = { git = "https://github.com/yancyribbens/rust-bitcoin", branch = "tmp/mark-txin-base-weight-public" }
bitcoin-units = { git = "https://github.com/yancyribbens/rust-bitcoin", branch = "tmp/mark-txin-base-weight-public" }
bitcoin-internals = { git = "https://github.com/yancyribbens/rust-bitcoin", branch = "tmp/mark-txin-base-weight-public" }

[[bench]]
name = "coin_selection"
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ To run the benchmarks use: `cargo bench`.

A basic performance comparison between this current [Rust BnB](https://github.com/p2pderivatives/rust-bitcoin-coin-selection/pull/28/files#diff-9098d62be93e83524a8371395c973d761a95000d1c295f600a8c808e917c16d9R122) implementation and the [Bitcoin Core](https://github.com/bitcoin/bitcoin/blob/4b1196a9855dcd188a24f393aa2fa21e2d61f061/src/wallet/coinselection.cpp#L76) version using commodity hardware (My rather old laptop).

|implementation|pool size|ns/iter|
|-------------:|---------|-------|
| Rust BnB| 1,000|936,560|
| C++ Core BnB| 1,000|816,374|
|implementation|pool size| ns/iter|
|-------------:|---------|---------|
| Rust BnB| 1,000|1,263,600|
| C++ Core BnB| 1,000| 816,374|

## Minimum Supported Rust Version (MSRV)

Expand Down
5 changes: 4 additions & 1 deletion benches/coin_selection.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};

use bitcoin::Amount;
use bitcoin::FeeRate;
use bitcoin::ScriptBuf;
use bitcoin::TxOut;
use bitcoin::Weight;
Expand Down Expand Up @@ -30,7 +31,9 @@ pub fn criterion_benchmark(c: &mut Criterion) {
let result = select_coins_bnb(
black_box(target),
black_box(cost_of_change),
black_box(&mut utxo_pool.clone()),
black_box(FeeRate::ZERO),
black_box(FeeRate::ZERO),
black_box(&mut utxo_pool),
)
.unwrap();
assert_eq!(2, result.len());
Expand Down
Loading

0 comments on commit bef818e

Please sign in to comment.