depolymerization

wire gateway for Bitcoin/Ethereum
Log | Files | Refs | Submodules | README | LICENSE

metadata.rs (1542B)


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