metadata.rs (1581B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2022-2025, 2026 Taler Systems SA 4 5 TALER is free software; you can redistribute it and/or modify it under the 6 terms of the GNU Affero General Public License as published by the Free Software 7 Foundation; either version 3, or (at your option) any later version. 8 9 TALER is distributed in the hope that it will be useful, but WITHOUT ANY 10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. 12 13 You should have received a copy of the GNU Affero General Public License along with 14 TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 */ 16 use bech32::Hrp; 17 use criterion::{Criterion, criterion_group, criterion_main}; 18 use depolymerizer_bitcoin::segwit::{decode_segwit_msg, encode_segwit_key, rand_addresses}; 19 use depolymerizer_common::rand_slice; 20 21 fn criterion_benchmark(c: &mut Criterion) { 22 let mut group = c.benchmark_group("SegWit addresses"); 23 let hrp = Hrp::parse("bench").unwrap(); 24 group.bench_function("encode", |b| { 25 b.iter_batched( 26 rand_slice, 27 |key| encode_segwit_key(hrp, &key), 28 criterion::BatchSize::SmallInput, 29 ); 30 }); 31 group.bench_function("decode", |b| { 32 b.iter_batched( 33 || rand_addresses(hrp, &rand_slice()), 34 |addrs| decode_segwit_msg(&addrs), 35 criterion::BatchSize::SmallInput, 36 ); 37 }); 38 } 39 40 criterion_group!(benches, criterion_benchmark); 41 criterion_main!(benches);