1
0
Fork 0
mirror of https://github.com/azalea-rs/simdnbt.git synced 2025-08-02 07:26:04 +00:00

add shen-nbt5 to benchmarks

This commit is contained in:
mat 2024-03-10 23:06:24 -05:00
parent 96f73c9de3
commit 2f963e1b71
2 changed files with 53 additions and 41 deletions

View file

@ -17,11 +17,13 @@ thiserror = "1.0.56"
[dev-dependencies]
criterion = { version = "0.5.1", features = ["html_reports"] }
graphite_binary = "0.1.0"
valence_nbt = { version = "0.8.0", features = ["binary"] }
fastnbt = "2.4.4"
azalea-nbt = { git = "https://github.com/azalea-rs/azalea", rev = "84e036ce3752ecf57904b0f5aff1f33d43e95a32" }
hematite-nbt = { version = "0.5.2", default-features = false }
shen-nbt5 = "0.4.4"
mimalloc = "0.1.39"

View file

@ -24,49 +24,59 @@ pub fn bench_read_file(filename: &str, c: &mut Criterion) {
let mut group = c.benchmark_group(format!("compare/{filename}"));
group.throughput(Throughput::Bytes(input.len() as u64));
// group.bench_function("simdnbt_borrow_parse", |b| {
// b.iter(|| {
// let input = black_box(input);
// let nbt = simdnbt::borrow::OptionalNbt::new(&mut Cursor::new(input))
// .unwrap()
// .unwrap();
// // let _ = black_box(nbt.list("").unwrap().ints());
// black_box(nbt);
// })
// });
let nbt = simdnbt::borrow::Nbt::read(&mut Cursor::new(input))
.unwrap()
.unwrap();
group.bench_function("simdnbt_borrow_write", |b| {
group.bench_function("simdnbt_borrow_parse", |b| {
b.iter(|| {
let mut out = Vec::new();
nbt.write(&mut out);
black_box(out);
let input = black_box(input);
let nbt = simdnbt::borrow::Nbt::read(&mut Cursor::new(input))
.unwrap()
.unwrap();
// let _ = black_box(nbt.list("").unwrap().ints());
black_box(nbt);
})
});
// group.bench_function("simdnbt_owned_parse", |b| {
// b.iter(|| {
// let input = black_box(input);
// let nbt = simdnbt::owned::OptionalNbt::new(&mut Cursor::new(input))
// let nbt = simdnbt::owned::Nbt::read(&mut Cursor::new(input))
// .unwrap()
// .unwrap();
// // let _ = black_box(nbt.list("").unwrap().ints());
// black_box(nbt);
// })
// });
let nbt = simdnbt::owned::Nbt::read(&mut Cursor::new(input))
.unwrap()
.unwrap();
group.bench_function("simdnbt_owned_write", |b| {
group.bench_function("shen_parse", |b| {
let mut input = black_box(input.to_vec());
b.iter(|| {
let mut out = Vec::new();
nbt.write(&mut out);
black_box(out);
let nbt = shen_nbt5::NbtValue::from_binary::<shen_nbt5::nbt_version::Java>(&mut input)
.unwrap();
black_box(nbt);
})
});
// let nbt = simdnbt::borrow::Nbt::read(&mut Cursor::new(input))
// .unwrap()
// .unwrap();
// group.bench_function("simdnbt_borrow_write", |b| {
// b.iter(|| {
// let mut out = Vec::new();
// nbt.write(&mut out);
// black_box(out);
// })
// });
// let nbt = simdnbt::owned::Nbt::read(&mut Cursor::new(input))
// .unwrap()
// .unwrap();
// group.bench_function("simdnbt_owned_write", |b| {
// b.iter(|| {
// let mut out = Vec::new();
// nbt.write(&mut out);
// black_box(out);
// })
// });
// group.bench_function("azalea_parse", |b| {
// b.iter(|| {
// let input = black_box(input);
@ -75,14 +85,14 @@ pub fn bench_read_file(filename: &str, c: &mut Criterion) {
// })
// });
let nbt = azalea_nbt::Nbt::read(&mut Cursor::new(input)).unwrap();
group.bench_function("azalea_write", |b| {
b.iter(|| {
let mut out = Vec::new();
nbt.write(&mut out);
black_box(out);
})
});
// let nbt = azalea_nbt::Nbt::read(&mut Cursor::new(input)).unwrap();
// group.bench_function("azalea_write", |b| {
// b.iter(|| {
// let mut out = Vec::new();
// nbt.write(&mut out);
// black_box(out);
// })
// });
// group.bench_function("graphite_parse", |b| {
// b.iter(|| {
@ -91,13 +101,13 @@ pub fn bench_read_file(filename: &str, c: &mut Criterion) {
// black_box(nbt);
// })
// });
let nbt = graphite_binary::nbt::decode::read(&mut &input[..]).unwrap();
group.bench_function("graphite_write", |b| {
b.iter(|| {
let out = graphite_binary::nbt::encode::write(&nbt);
black_box(out);
})
});
// let nbt = graphite_binary::nbt::decode::read(&mut &input[..]).unwrap();
// group.bench_function("graphite_write", |b| {
// b.iter(|| {
// let out = graphite_binary::nbt::encode::write(&nbt);
// black_box(out);
// })
// });
// group.bench_function("valence_parse", |b| {
// b.iter(|| {