有必要加个GB了

This commit is contained in:
shenjack 2024-01-13 02:14:18 +08:00
parent 6af2c284c9
commit d0ce0ef3b3
Signed by: shenjack
GPG Key ID: 7B1134A979775551
3 changed files with 5 additions and 7 deletions

View File

@ -4,5 +4,3 @@ version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View File

@ -5,7 +5,6 @@ pub struct NbtData {
pub data: Vec<u8>,
}
impl NbtData {
pub fn new(data: Vec<u8>) -> Self { Self { head: 0, data } }
pub fn get_mut(&mut self) -> &mut [u8] {
@ -140,7 +139,6 @@ pub mod raw_reading {
}
}
#[derive(Debug)]
pub enum Value<'value> {
// 还有一个 End: 0
@ -170,7 +168,6 @@ pub enum Value<'value> {
Compound(Vec<(String, Value<'value>)>),
}
#[derive(Debug)]
pub enum ListContent<'value> {
ByteList(Vec<i8>),
@ -187,7 +184,6 @@ pub enum ListContent<'value> {
ListList(Vec<ListContent<'value>>),
}
impl<'value> Value<'value> {
#[inline(always)]
pub fn read_byte(data: &mut NbtData) -> Self { Self::Byte(data.read_byte()) }

View File

@ -138,7 +138,7 @@ fn big_read_test() {
fn read_test(data: Vec<u8>) {
let len = data.len();
let start_time = std::time::Instant::now();
let data = data_struct::Value::from_vec(data);
let _data = data_struct::Value::from_vec(data);
let end_time = std::time::Instant::now();
println!("===local nbt===");
println!("time: {:?}", end_time - start_time);
@ -148,5 +148,9 @@ fn read_test(data: Vec<u8>) {
"{:?} (mb/sec)",
len as f64 / (end_time - start_time).as_secs_f64() / 1024.0 / 1024.0
);
println!(
"{:?} (gb/sec)",
len as f64 / (end_time - start_time).as_secs_f64() / 1024.0 / 1024.0 / 1024.0
);
// println!("{:?}", data);
}