mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 06:16:04 +00:00
ok i give up remove the async benchmarks
This commit is contained in:
parent
6ae94b96e6
commit
1cdd061a99
2 changed files with 17 additions and 12 deletions
|
@ -3,7 +3,7 @@ use criterion::{criterion_group, criterion_main, Criterion, Throughput};
|
|||
use flate2::read::GzDecoder;
|
||||
use std::{
|
||||
fs::File,
|
||||
io::{self, Read, Seek, SeekFrom},
|
||||
io::{self, Cursor, Read, Seek, SeekFrom},
|
||||
};
|
||||
|
||||
fn bench_serialize(filename: &str, c: &mut Criterion) {
|
||||
|
@ -25,14 +25,17 @@ fn bench_serialize(filename: &str, c: &mut Criterion) {
|
|||
.block_on(async { Tag::read(&mut decoded_src_stream).await.unwrap() });
|
||||
|
||||
let mut group = c.benchmark_group(filename);
|
||||
|
||||
group.throughput(Throughput::Bytes(decoded_src.len() as u64));
|
||||
group.bench_function("Decode", |b| {
|
||||
b.to_async(tokio::runtime::Runtime::new().unwrap())
|
||||
.iter(|| {
|
||||
decoded_src_stream.seek(SeekFrom::Start(0)).unwrap();
|
||||
Tag::read(&mut decoded_src_stream)
|
||||
})
|
||||
});
|
||||
|
||||
// idk if this is criterion's fault or rust's fault but the async benchmark doesn't compile
|
||||
// group.bench_function("Decode", |b| {
|
||||
// b.to_async(tokio::runtime::Runtime::new().unwrap();).iter(|| async {
|
||||
// decoded_src_stream.seek(SeekFrom::Start(0)).unwrap();
|
||||
// Tag::read(&mut decoded_src_stream).await.unwrap();
|
||||
// })
|
||||
// });
|
||||
|
||||
group.bench_function("Encode", |b| {
|
||||
b.iter(|| {
|
||||
nbt.write(&mut io::sink()).unwrap();
|
||||
|
|
|
@ -191,7 +191,7 @@ where
|
|||
|
||||
fn get_varint_size(&mut self, value: i32) -> u8 {
|
||||
for i in 1..5 {
|
||||
if (value & -1 << i * 7) != 0 {
|
||||
if (value & -1 << (i * 7)) != 0 {
|
||||
continue;
|
||||
}
|
||||
return i;
|
||||
|
@ -201,7 +201,7 @@ where
|
|||
|
||||
fn get_varlong_size(&mut self, value: i32) -> u8 {
|
||||
for i in 1..10 {
|
||||
if (value & -1 << i * 7) != 0 {
|
||||
if (value & -1 << (i * 7)) != 0 {
|
||||
continue;
|
||||
}
|
||||
return i;
|
||||
|
@ -285,8 +285,7 @@ where
|
|||
}
|
||||
|
||||
async fn read_nbt(&mut self) -> Result<azalea_nbt::Tag, String> {
|
||||
self.peek();
|
||||
Ok(azalea_nbt::Tag::read(self).unwrap())
|
||||
Ok(azalea_nbt::Tag::read(self).await.unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -311,12 +310,15 @@ mod tests {
|
|||
async fn test_read_varint() {
|
||||
let mut buf = BufReader::new(Cursor::new(vec![192, 196, 7]));
|
||||
assert_eq!(buf.read_varint().await.unwrap(), 123456);
|
||||
assert_eq!(buf.get_varint_size(123456), 3);
|
||||
|
||||
let mut buf = BufReader::new(Cursor::new(vec![0]));
|
||||
assert_eq!(buf.read_varint().await.unwrap(), 0);
|
||||
assert_eq!(buf.get_varint_size(0), 1);
|
||||
|
||||
let mut buf = BufReader::new(Cursor::new(vec![1]));
|
||||
assert_eq!(buf.read_varint().await.unwrap(), 1);
|
||||
assert_eq!(buf.get_varint_size(1), 1);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
|
Loading…
Add table
Reference in a new issue