Files
cdk/crates/cdk-common/benches/transaction_id_benchmark.rs
tsk 95aa64477a Improve add transaction (#1164)
* fix(wallet): move transaction ID calculation before database operations

* fix(sql): remove on ys from on conflict transaction insert

Since the id is created from the ys we know that if there is a conflict
the ys are the same and do not need to be updated.

* feat: bench for transactio id

* chore: fmt
2025-10-09 16:20:06 +01:00

30 lines
812 B
Rust

use cashu::nuts::nut01::SecretKey;
use cashu::PublicKey;
use cdk_common::wallet::TransactionId;
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
fn generate_public_keys(count: usize) -> Vec<PublicKey> {
(0..count)
.map(|_| SecretKey::generate().public_key())
.collect()
}
fn bench_transaction_id(c: &mut Criterion) {
let mut group = c.benchmark_group("TransactionId::new");
let sizes = vec![1, 10, 50, 100, 500];
for size in sizes {
let public_keys = generate_public_keys(size);
group.bench_with_input(BenchmarkId::from_parameter(size), &size, |b, _| {
b.iter(|| TransactionId::new(public_keys.clone()));
});
}
group.finish();
}
criterion_group!(benches, bench_transaction_id);
criterion_main!(benches);