From b03d3da65937aebcba1cb38573d02267e49bfe19 Mon Sep 17 00:00:00 2001 From: mat Date: Fri, 22 Apr 2022 18:23:29 +0000 Subject: inline reading in nbt decoding --- azalea-nbt/benches/my_benchmark.rs | 26 +++++++++++++------------- azalea-nbt/src/decode.rs | 1 + 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/azalea-nbt/benches/my_benchmark.rs b/azalea-nbt/benches/my_benchmark.rs index 528475d3..00d12dc8 100755 --- a/azalea-nbt/benches/my_benchmark.rs +++ b/azalea-nbt/benches/my_benchmark.rs @@ -29,20 +29,20 @@ fn bench_serialize(filename: &str, c: &mut Criterion) { group.throughput(Throughput::Bytes(decoded_src.len() as u64)); - // group.bench_function("Decode", |b| { - // b.to_async(tokio::runtime::Runtime::new().unwrap()) - // .iter(|| async { - // let mut owned_decoded_src_stream = decoded_src_stream.clone(); - // owned_decoded_src_stream.seek(SeekFrom::Start(0)).unwrap(); - // Tag::read(&mut owned_decoded_src_stream).await.unwrap(); - // }) - // }); - - group.bench_function("Encode", |b| { - b.iter(|| { - nbt.write(&mut io::sink()).unwrap(); - }) + group.bench_function("Decode", |b| { + b.to_async(tokio::runtime::Runtime::new().unwrap()) + .iter(|| async { + let mut owned_decoded_src_stream = decoded_src_stream.clone(); + owned_decoded_src_stream.seek(SeekFrom::Start(0)).unwrap(); + Tag::read(&mut owned_decoded_src_stream).await.unwrap(); + }) }); + + // group.bench_function("Encode", |b| { + // b.iter(|| { + // nbt.write(&mut io::sink()).unwrap(); + // }) + // }); group.finish(); } diff --git a/azalea-nbt/src/decode.rs b/azalea-nbt/src/decode.rs index e4968811..3e2f7adb 100755 --- a/azalea-nbt/src/decode.rs +++ b/azalea-nbt/src/decode.rs @@ -21,6 +21,7 @@ where } impl Tag { + #[inline] #[async_recursion] async fn read_known(stream: &mut R, id: u8) -> Result where -- cgit v1.2.3