Skip to content

Commit

Permalink
Merge pull request #521 from Chia-Network/serializer-benchmark
Browse files Browse the repository at this point in the history
add benchmark for Serializer, to run next to node_to_bytes_backrefs()
  • Loading branch information
arvidn authored Jan 2, 2025
2 parents fd65fed + 582f473 commit 709ecc7
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 @@ -32,6 +32,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 709ecc7

Please sign in to comment.