Skip to content

Commit 27a0c9b

Browse files
committed
chore: gate criterion benches behind cfg(bdk_bench)
ci: bump nightly docs toolchain to 2024-11-17
1 parent 0646980 commit 27a0c9b

File tree

7 files changed

+19
-7
lines changed

7 files changed

+19
-7
lines changed

.github/workflows/nightly_docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
- name: Checkout sources
1111
uses: actions/checkout@v4
1212
- name: Set default toolchain
13-
run: rustup default nightly-2024-05-12
13+
run: rustup default nightly-2024-11-17
1414
- name: Set profile
1515
run: rustup set profile minimal
1616
- name: Update toolchain

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,9 @@ authors = ["Bitcoin Dev Kit Developers"]
2626
[workspace.lints.clippy]
2727
print_stdout = "deny"
2828
print_stderr = "deny"
29+
30+
[workspace.lints.rust.unexpected_cfgs]
31+
level = "forbid"
32+
check-cfg = [
33+
"cfg(bdk_bench)",
34+
]

bench/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ name = "bench"
88
harness = false
99

1010
[dependencies]
11-
bdk_chain = { path = "../crates/chain" }
11+
bdk_chain = { path = "../crates/chain", features = ["criterion"] }
1212
criterion = { version = "0.5", default-features = false }

bench/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
# To run benches
1+
# BDK bench
22

3-
`cargo bench`
3+
To run benchmarks in the current directory:
4+
5+
`RUSTFLAGS="--cfg=bdk_bench" cargo bench`

crates/chain/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ bitcoin = { version = "0.32.0", default-features = false }
2020
bdk_core = { path = "../core", version = "0.3.0", default-features = false }
2121
serde = { version = "1", optional = true, features = ["derive", "rc"] }
2222
miniscript = { version = "12.0.0", optional = true, default-features = false }
23-
criterion = { version = "0.5", default-features = false }
2423

2524
# Feature dependencies
2625
rusqlite = { version = "0.31.0", features = ["bundled"], optional = true }
@@ -31,6 +30,9 @@ rand = "0.8"
3130
proptest = "1.2.0"
3231
bdk_testenv = { path = "../testenv", default-features = false }
3332

33+
[target.'cfg(bdk_bench)'.dependencies]
34+
criterion = { version = "0.5", optional = true, default-features = false }
35+
3436

3537
[features]
3638
default = ["std", "miniscript"]

crates/chain/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ pub use bdk_core::*;
6868
#[allow(unused_imports)]
6969
#[macro_use]
7070
extern crate alloc;
71+
#[cfg(bdk_bench)]
72+
extern crate criterion;
7173
#[cfg(feature = "rusqlite")]
7274
pub extern crate rusqlite;
7375
#[cfg(feature = "serde")]

crates/chain/src/tx_graph.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,6 +1557,7 @@ fn tx_outpoint_range(txid: Txid) -> RangeInclusive<OutPoint> {
15571557
/// Bench
15581558
#[allow(unused)]
15591559
#[allow(missing_docs)]
1560+
#[cfg(bdk_bench)]
15601561
pub mod bench {
15611562
use std::str::FromStr;
15621563

@@ -1652,14 +1653,13 @@ pub mod bench {
16521653
pub fn filter_chain_unspents(bench: &mut Criterion) {
16531654
let (graph, chain) = get_params();
16541655
// TODO: insert conflicts
1655-
let outpoints = graph.index.outpoints().clone();
16561656
bench.bench_function("filter_chain_unspents", |b| {
16571657
b.iter(|| {
16581658
TxGraph::filter_chain_unspents(
16591659
graph.graph(),
16601660
&chain,
16611661
chain.tip().block_id(),
1662-
outpoints.clone(),
1662+
graph.index.outpoints().clone(),
16631663
)
16641664
})
16651665
});

0 commit comments

Comments
 (0)