Skip to content

Commit c7bfcbf

Browse files
committed
add simple RedeemNode benchmark
We are going to change a bunch of stuff about type inference, so add a benchmark for decoding a fixed program that's available. This is not the best benchmark, but it's one that's available. On my system the current results is: 70,972.00 ns/iter (+/- 662.39)
1 parent 6934a57 commit c7bfcbf

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/node/redeem.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,3 +1102,39 @@ main := comp input comp process jet_verify : 1 -> 1"#;
11021102
);
11031103
}
11041104
}
1105+
1106+
#[cfg(bench)]
1107+
#[cfg(feature = "elements")]
1108+
mod benches {
1109+
use super::*;
1110+
1111+
use crate::bit_encoding::BitIter;
1112+
use crate::jet::Elements;
1113+
1114+
use test::{black_box, Bencher};
1115+
1116+
#[bench]
1117+
fn decode_fixed_program(bh: &mut Bencher) {
1118+
let prog = &[
1119+
0xd3, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b,
1120+
0x78, 0xce, 0x56, 0x3f, 0x89, 0xa0, 0xed, 0x94, 0x14, 0xf5, 0xaa, 0x28, 0xad, 0x0d,
1121+
0x96, 0xd6, 0x79, 0x5f, 0x9c, 0x63, 0x47, 0x07, 0x02, 0xc0, 0xe2, 0x8d, 0x88, 0x10,
1122+
][..];
1123+
let witness = &[
1124+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b, 0x78, 0xce,
1125+
0x56, 0x3f, 0x89, 0xa0, 0xed, 0x94, 0x14, 0xf5, 0xaa, 0x28, 0xad, 0x0d, 0x96, 0xd6,
1126+
0x79, 0x5f, 0x9c, 0x63, 0xdb, 0x86, 0x8d, 0x45, 0xa0, 0xbc, 0x1d, 0x19, 0x01, 0x30,
1127+
0x2b, 0xc8, 0x7a, 0x87, 0x1c, 0xf1, 0x58, 0xe2, 0xbd, 0xe2, 0xcf, 0xa6, 0x45, 0xa8,
1128+
0x95, 0xc1, 0xb4, 0x5d, 0x68, 0xea, 0x24, 0xc0,
1129+
][..];
1130+
bh.iter(|| {
1131+
let prog = BitIter::from(prog);
1132+
let witness = BitIter::from(witness);
1133+
black_box(RedeemNode::<Elements>::decode(
1134+
black_box(prog),
1135+
black_box(witness),
1136+
))
1137+
.unwrap();
1138+
});
1139+
}
1140+
}

0 commit comments

Comments
 (0)