1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 06:16:04 +00:00

inline reading in nbt decoding

This commit is contained in:
mat 2022-04-22 18:23:29 +00:00
parent 99652200aa
commit b03d3da659
2 changed files with 14 additions and 13 deletions

View file

@ -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();
}

View file

@ -21,6 +21,7 @@ where
}
impl Tag {
#[inline]
#[async_recursion]
async fn read_known<R>(stream: &mut R, id: u8) -> Result<Tag, Error>
where