Skip to content

Commit

Permalink
add benchmark for Serializer, to run next to node_to_bytes_backrefs()
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed Dec 28, 2024
1 parent 9a0ed3a commit 582f473
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion benches/serialize.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clvmr::allocator::Allocator;
use clvmr::serde::{
node_from_bytes, node_from_bytes_backrefs, node_to_bytes, node_to_bytes_backrefs,
node_from_bytes, node_from_bytes_backrefs, node_to_bytes, node_to_bytes_backrefs, Serializer,
};
use criterion::black_box;
use criterion::{criterion_group, criterion_main, Criterion};
Expand Down Expand Up @@ -31,6 +31,16 @@ fn serialize_benchmark(c: &mut Criterion) {
start.elapsed()
})
});

group.bench_function(format!("Serializer {name}"), |b| {
b.iter(|| {
let start = Instant::now();
let mut ser = Serializer::default();
let _ = ser.add(&a, node, None);
black_box(ser.into_inner());
start.elapsed()
})
});
}

group.finish();
Expand Down

0 comments on commit 582f473

Please sign in to comment.