Skip to content

Commit

Permalink
Add rbx_binary 10,000 parts benchmarks (#461)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethloeffler authored Oct 28, 2024
1 parent addac3d commit 9739d9f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
Binary file added rbx_binary/bench-files/parts-10000.rbxm
Binary file not shown.
13 changes: 12 additions & 1 deletion rbx_binary/benches/deserializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ pub fn de_modulescripts_100_lines_100(c: &mut Criterion) {
});
}

pub fn de_parts_10000(c: &mut Criterion) {
static BUFFER: &[u8] = include_bytes!("../bench-files/parts-10000.rbxm");

c.bench_function("Deserialize 10,000 Parts", |b| {
b.iter(|| {
deserialize_bench(BUFFER);
});
});
}

#[inline(always)]
fn deserialize_bench(buffer: &[u8]) {
rbx_binary::from_reader(buffer).unwrap();
Expand All @@ -39,6 +49,7 @@ criterion_group!(
deserializer,
de_folders_100,
de_deep_folders_100,
de_modulescripts_100_lines_100
de_modulescripts_100_lines_100,
de_parts_10000
);
criterion_main!(deserializer);
19 changes: 18 additions & 1 deletion rbx_binary/benches/serializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,22 @@ pub fn ser_folders_100(c: &mut Criterion) {
});
}

criterion_group!(serializer, ser_folders_100);
pub fn ser_parts_10000(c: &mut Criterion) {
static BUFFER: &[u8] = include_bytes!("../bench-files/parts-10000.rbxm");
let tree = rbx_binary::from_reader(BUFFER).unwrap();
let root_ref = tree.root_ref();

let mut buffer = Vec::new();
rbx_binary::to_writer(&mut buffer, &tree, &[root_ref]).unwrap();
buffer.clear();

c.bench_function("Serialize 10,000 Parts", |b| {
b.iter(|| {
rbx_binary::to_writer(&mut buffer, &tree, &[root_ref]).unwrap();
buffer.clear();
})
});
}

criterion_group!(serializer, ser_folders_100, ser_parts_10000);
criterion_main!(serializer);

0 comments on commit 9739d9f

Please sign in to comment.