Add more benchmarks for CircuitAccount
@@ -92,6 +92,27 @@ fn bench_circuit_account_transform(b: &mut Bencher<'_>) {
);
}
+/// Measures time to execute `CircuitAccount::default()`.
+fn circuit_account_default(b: &mut Bencher<'_>) {
+ b.iter_with_large_drop(|| {
+ let _ = black_box(CircuitAccount::default());
+ });
+}
+
+/// Measures time to execute `CircuitAccount::default().get_bits_le()`.
+fn bench_circuit_account_get_bits_le_default(b: &mut Bencher<'_>) {
+ let circuit_account = CircuitAccount::default();
+ let setup = || circuit_account.clone();
+
+ b.iter_batched_ref(
+ setup,
+ |circuit_account| {
+ let _ = black_box(circuit_account.get_bits_le());
+ },
+ BatchSize::SmallInput,
+ );
+}
+
/// `get_bits_le` is a method internally used by SMT to calculate the hash of the element.
///
/// `n_balances` parameter specifies the amount of elements in the balance tree.
@@ -141,7 +162,10 @@ pub fn bench_primitives(c: &mut Criterion) {
bench_circuit_account_transform,
);
+ c.bench_function("circuit_account_default", circuit_account_default);
+
let mut group = c.benchmark_group("bench_circuit_account_get_bits_le");
+ group.bench_function("default account", bench_circuit_account_get_bits_le_default);
for n_balances in [0, 10, 100, 1000] {
group.bench_function(&format!("n_balances: {}", n_balances), |b| {
bench_circuit_account_get_bits_le(b, n_balances)
