大端序啊喂!
2000MB/s!
This commit is contained in:
parent
5c0ef76028
commit
b78187b3f2
@ -1,4 +1,4 @@
|
|||||||
use std::{borrow::Cow, collections::HashMap};
|
use std::borrow::Cow;
|
||||||
|
|
||||||
/// NBT 里除了字符串的长度量都是 i32
|
/// NBT 里除了字符串的长度量都是 i32
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
@ -31,12 +31,12 @@ impl NbtData {
|
|||||||
value
|
value
|
||||||
}
|
}
|
||||||
pub fn read_short(&mut self) -> i16 {
|
pub fn read_short(&mut self) -> i16 {
|
||||||
let value = i16::from_le_bytes([self.data[self.head], self.data[self.head + 1]]);
|
let value = i16::from_be_bytes([self.data[self.head], self.data[self.head + 1]]);
|
||||||
self.head += 2;
|
self.head += 2;
|
||||||
value
|
value
|
||||||
}
|
}
|
||||||
pub fn read_int(&mut self) -> i32 {
|
pub fn read_int(&mut self) -> i32 {
|
||||||
let value = i32::from_le_bytes([
|
let value = i32::from_be_bytes([
|
||||||
self.data[self.head],
|
self.data[self.head],
|
||||||
self.data[self.head + 1],
|
self.data[self.head + 1],
|
||||||
self.data[self.head + 2],
|
self.data[self.head + 2],
|
||||||
@ -46,7 +46,7 @@ impl NbtData {
|
|||||||
value
|
value
|
||||||
}
|
}
|
||||||
pub fn read_long(&mut self) -> i64 {
|
pub fn read_long(&mut self) -> i64 {
|
||||||
let value = i64::from_le_bytes([
|
let value = i64::from_be_bytes([
|
||||||
self.data[self.head],
|
self.data[self.head],
|
||||||
self.data[self.head + 1],
|
self.data[self.head + 1],
|
||||||
self.data[self.head + 2],
|
self.data[self.head + 2],
|
||||||
@ -60,7 +60,7 @@ impl NbtData {
|
|||||||
value
|
value
|
||||||
}
|
}
|
||||||
pub fn read_float(&mut self) -> f32 {
|
pub fn read_float(&mut self) -> f32 {
|
||||||
let value = f32::from_le_bytes([
|
let value = f32::from_be_bytes([
|
||||||
self.data[self.head],
|
self.data[self.head],
|
||||||
self.data[self.head + 1],
|
self.data[self.head + 1],
|
||||||
self.data[self.head + 2],
|
self.data[self.head + 2],
|
||||||
@ -70,7 +70,7 @@ impl NbtData {
|
|||||||
value
|
value
|
||||||
}
|
}
|
||||||
pub fn read_double(&mut self) -> f64 {
|
pub fn read_double(&mut self) -> f64 {
|
||||||
let value = f64::from_le_bytes([
|
let value = f64::from_be_bytes([
|
||||||
self.data[self.head],
|
self.data[self.head],
|
||||||
self.data[self.head + 1],
|
self.data[self.head + 1],
|
||||||
self.data[self.head + 2],
|
self.data[self.head + 2],
|
||||||
@ -102,7 +102,7 @@ pub mod raw_reading {
|
|||||||
} else {
|
} else {
|
||||||
(slice.len() / 2) as usize
|
(slice.len() / 2) as usize
|
||||||
};
|
};
|
||||||
Some(unsafe { Vec::from_raw_parts(slice.as_ptr() as *mut i16, length, length) })
|
Some(unsafe { std::slice::from_raw_parts(slice.as_ptr() as *mut i16, length).to_vec() })
|
||||||
}
|
}
|
||||||
/// 开始 unsafe 了
|
/// 开始 unsafe 了
|
||||||
/// unsafe rust, 小子!
|
/// unsafe rust, 小子!
|
||||||
@ -112,7 +112,7 @@ pub mod raw_reading {
|
|||||||
} else {
|
} else {
|
||||||
(slice.len() / 4) as usize
|
(slice.len() / 4) as usize
|
||||||
};
|
};
|
||||||
Some(unsafe { Vec::from_raw_parts(slice.as_ptr() as *mut i32, 4, length) })
|
Some(unsafe { std::slice::from_raw_parts(slice.as_ptr() as *mut i32, length).to_vec() })
|
||||||
}
|
}
|
||||||
/// 这边也是 unsafe 捏
|
/// 这边也是 unsafe 捏
|
||||||
pub fn slice_as_long_array(slice: &[u8]) -> Option<Vec<i64>> {
|
pub fn slice_as_long_array(slice: &[u8]) -> Option<Vec<i64>> {
|
||||||
@ -121,7 +121,7 @@ pub mod raw_reading {
|
|||||||
} else {
|
} else {
|
||||||
(slice.len() / 8) as usize
|
(slice.len() / 8) as usize
|
||||||
};
|
};
|
||||||
Some(unsafe { Vec::from_raw_parts(slice.as_ptr() as *mut i64, 8, length) })
|
Some(unsafe { std::slice::from_raw_parts(slice.as_ptr() as *mut i64, length).to_vec() })
|
||||||
}
|
}
|
||||||
/// 这边也是 unsafe 捏
|
/// 这边也是 unsafe 捏
|
||||||
pub fn slice_as_float_array(slice: &[u8]) -> Option<Vec<f32>> {
|
pub fn slice_as_float_array(slice: &[u8]) -> Option<Vec<f32>> {
|
||||||
@ -130,7 +130,7 @@ pub mod raw_reading {
|
|||||||
} else {
|
} else {
|
||||||
(slice.len() / 4) as usize
|
(slice.len() / 4) as usize
|
||||||
};
|
};
|
||||||
Some(unsafe { Vec::from_raw_parts(slice.as_ptr() as *mut f32, 4, length) })
|
Some(unsafe { std::slice::from_raw_parts(slice.as_ptr() as *mut f32, length).to_vec() })
|
||||||
}
|
}
|
||||||
/// 这边也是 unsafe 捏
|
/// 这边也是 unsafe 捏
|
||||||
pub fn slice_as_double_array(slice: &[u8]) -> Option<Vec<f64>> {
|
pub fn slice_as_double_array(slice: &[u8]) -> Option<Vec<f64>> {
|
||||||
@ -139,11 +139,12 @@ pub mod raw_reading {
|
|||||||
} else {
|
} else {
|
||||||
(slice.len() / 8) as usize
|
(slice.len() / 8) as usize
|
||||||
};
|
};
|
||||||
Some(unsafe { Vec::from_raw_parts(slice.as_ptr() as *mut f64, 8, length) })
|
Some(unsafe { std::slice::from_raw_parts(slice.as_ptr() as *mut f64, length).to_vec() })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
|
#[derive(Debug)]
|
||||||
pub enum Value<'value> {
|
pub enum Value<'value> {
|
||||||
// 还有一个 End: 0
|
// 还有一个 End: 0
|
||||||
/// 1
|
/// 1
|
||||||
@ -169,11 +170,11 @@ pub enum Value<'value> {
|
|||||||
/// 9
|
/// 9
|
||||||
List(ListContent<'value>),
|
List(ListContent<'value>),
|
||||||
/// 10
|
/// 10
|
||||||
Compound(HashMap<Cow<'value, str>, Value<'value>>),
|
Compound(Vec<(String, Value<'value>)>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
#[allow(unused)]
|
#[derive(Debug)]
|
||||||
pub enum ListContent<'value> {
|
pub enum ListContent<'value> {
|
||||||
ByteList(Vec<i8>),
|
ByteList(Vec<i8>),
|
||||||
ShortList(Vec<i16>),
|
ShortList(Vec<i16>),
|
||||||
@ -185,7 +186,7 @@ pub enum ListContent<'value> {
|
|||||||
ByteArrayList(Vec<Vec<i8>>),
|
ByteArrayList(Vec<Vec<i8>>),
|
||||||
IntArrayList(Vec<Vec<i32>>),
|
IntArrayList(Vec<Vec<i32>>),
|
||||||
LongArrayList(Vec<Vec<i64>>),
|
LongArrayList(Vec<Vec<i64>>),
|
||||||
CompoundList(Vec<HashMap<String, Value<'value>>>),
|
CompoundList(Vec<Vec<(String, Value<'value>)>>),
|
||||||
ListList(Vec<ListContent<'value>>),
|
ListList(Vec<ListContent<'value>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,16 +273,19 @@ impl<'value> Value<'value> {
|
|||||||
let mut list = Vec::with_capacity(length as usize);
|
let mut list = Vec::with_capacity(length as usize);
|
||||||
for _ in 0..length {
|
for _ in 0..length {
|
||||||
let inner_list = Self::read_list(data);
|
let inner_list = Self::read_list(data);
|
||||||
let value = match inner_list {
|
let value = inner_list.into_list().unwrap();
|
||||||
Self::List(value) => value,
|
|
||||||
_ => panic!("WTF, type_id = {}", type_id),
|
|
||||||
};
|
|
||||||
list.push(value);
|
list.push(value);
|
||||||
}
|
}
|
||||||
Self::List(ListContent::ListList(list))
|
Self::List(ListContent::ListList(list))
|
||||||
}
|
}
|
||||||
10 => {
|
10 => {
|
||||||
todo!("CompoundList, wait for Compound impl")
|
let mut list = Vec::with_capacity(length as usize);
|
||||||
|
for _ in 0..length {
|
||||||
|
let inner_compound = Self::read_compound(data);
|
||||||
|
let value = inner_compound.into_compound().unwrap();
|
||||||
|
list.push(value);
|
||||||
|
}
|
||||||
|
Self::List(ListContent::CompoundList(list))
|
||||||
}
|
}
|
||||||
11 => {
|
11 => {
|
||||||
let mut list = Vec::with_capacity(length as usize);
|
let mut list = Vec::with_capacity(length as usize);
|
||||||
@ -308,9 +312,12 @@ impl<'value> Value<'value> {
|
|||||||
}
|
}
|
||||||
pub fn read_compound(data: &mut NbtData) -> Self {
|
pub fn read_compound(data: &mut NbtData) -> Self {
|
||||||
let mut type_id = 1;
|
let mut type_id = 1;
|
||||||
let mut map = std::collections::HashMap::new();
|
let mut list = vec![];
|
||||||
while type_id != 0 {
|
while type_id != 0 {
|
||||||
type_id = data.read_byte();
|
type_id = data.read_byte();
|
||||||
|
if type_id == 0 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
let name_len = data.read_short();
|
let name_len = data.read_short();
|
||||||
let name = String::from_utf8(data.read_bytes(name_len as usize)).unwrap();
|
let name = String::from_utf8(data.read_bytes(name_len as usize)).unwrap();
|
||||||
let value = match type_id {
|
let value = match type_id {
|
||||||
@ -344,9 +351,9 @@ impl<'value> Value<'value> {
|
|||||||
}
|
}
|
||||||
_ => panic!("WTF, type_id = {}", type_id),
|
_ => panic!("WTF, type_id = {}", type_id),
|
||||||
};
|
};
|
||||||
map.insert(name.into(), value);
|
list.push((name, value));
|
||||||
}
|
}
|
||||||
Self::Compound(map)
|
Self::Compound(list)
|
||||||
}
|
}
|
||||||
pub fn as_byte(&self) -> Option<i8> {
|
pub fn as_byte(&self) -> Option<i8> {
|
||||||
match self {
|
match self {
|
||||||
@ -396,28 +403,49 @@ impl<'value> Value<'value> {
|
|||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn as_compound(&self) -> Option<&HashMap<Cow<'value, str>, Value<'value>>> {
|
pub fn as_compound(&self) -> Option<&Vec<(String, Value<'value>)>> {
|
||||||
match self {
|
match self {
|
||||||
Self::Compound(value) => Some(value),
|
Self::Compound(value) => Some(value),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn as_byte_array(&self) -> Option<&[i8]> {
|
pub fn as_byte_array(&self) -> Option<&Vec<i8>> {
|
||||||
match self {
|
match self {
|
||||||
Self::ByteArray(value) => Some(value),
|
Self::ByteArray(value) => Some(value),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn as_int_array(&self) -> Option<&[i32]> {
|
pub fn as_int_array(&self) -> Option<&Vec<i32>> {
|
||||||
match self {
|
match self {
|
||||||
Self::IntArray(value) => Some(value),
|
Self::IntArray(value) => Some(value),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn as_long_array(&self) -> Option<&[i64]> {
|
pub fn as_long_array(&self) -> Option<&Vec<i64>> {
|
||||||
match self {
|
match self {
|
||||||
Self::LongArray(value) => Some(value),
|
Self::LongArray(value) => Some(value),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pub fn into_list(self) -> Option<ListContent<'value>> {
|
||||||
|
match self {
|
||||||
|
Self::List(value) => Some(value),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn into_compound(self) -> Option<Vec<(String, Value<'value>)>> {
|
||||||
|
match self {
|
||||||
|
Self::Compound(value) => Some(value),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn from_vec(data: Vec<u8>) -> Self {
|
||||||
|
let mut nbt_data = NbtData::new(data);
|
||||||
|
let _type_id = nbt_data.read_byte();
|
||||||
|
let _name_len = nbt_data.read_short();
|
||||||
|
println!("{} {}", _type_id, _name_len);
|
||||||
|
let name = String::from_utf8(nbt_data.read_bytes(_name_len as usize)).unwrap();
|
||||||
|
println!("{}", name);
|
||||||
|
Value::read_compound(&mut nbt_data)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
149
v2/src/main.rs
149
v2/src/main.rs
@ -1,5 +1,152 @@
|
|||||||
mod data_struct;
|
mod data_struct;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello, world!");
|
small_read_test();
|
||||||
|
big_read_test();
|
||||||
|
cli_read_test();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn cli_read_test() {
|
||||||
|
let mut args = std::env::args();
|
||||||
|
// 如果有, 取出
|
||||||
|
if let Some(arg) = args.nth(1) {
|
||||||
|
let data = std::fs::read(arg).unwrap();
|
||||||
|
read_test(data);
|
||||||
|
} else {
|
||||||
|
println!("Usage: cargo run --release -- <file>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn small_read_test() {
|
||||||
|
let data: [u8; 0x21] = [
|
||||||
|
0x0A, 0x00, 0x0B, 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x08,
|
||||||
|
0x00, 0x04, 0x6E, 0x61, 0x6D, 0x65, 0x00, 0x09, 0x42, 0x61, 0x6E, 0x61, 0x6E, 0x72, 0x61,
|
||||||
|
0x6D, 0x61, 0x00,
|
||||||
|
];
|
||||||
|
read_test(data.to_vec());
|
||||||
|
}
|
||||||
|
|
||||||
|
fn big_read_test() {
|
||||||
|
let data: [u8; 0x608] = [
|
||||||
|
0x0A, 0x00, 0x05, 0x4C, 0x65, 0x76, 0x65, 0x6C, 0x04, 0x00, 0x08, 0x6C, 0x6F, 0x6E, 0x67,
|
||||||
|
0x54, 0x65, 0x73, 0x74, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x02, 0x00, 0x09,
|
||||||
|
0x73, 0x68, 0x6F, 0x72, 0x74, 0x54, 0x65, 0x73, 0x74, 0x7F, 0xFF, 0x08, 0x00, 0x0A, 0x73,
|
||||||
|
0x74, 0x72, 0x69, 0x6E, 0x67, 0x54, 0x65, 0x73, 0x74, 0x00, 0x29, 0x48, 0x45, 0x4C, 0x4C,
|
||||||
|
0x4F, 0x20, 0x57, 0x4F, 0x52, 0x4C, 0x44, 0x20, 0x54, 0x48, 0x49, 0x53, 0x20, 0x49, 0x53,
|
||||||
|
0x20, 0x41, 0x20, 0x54, 0x45, 0x53, 0x54, 0x20, 0x53, 0x54, 0x52, 0x49, 0x4E, 0x47, 0x20,
|
||||||
|
0xC3, 0x85, 0xC3, 0x84, 0xC3, 0x96, 0x21, 0x05, 0x00, 0x09, 0x66, 0x6C, 0x6F, 0x61, 0x74,
|
||||||
|
0x54, 0x65, 0x73, 0x74, 0x3E, 0xFF, 0x18, 0x32, 0x03, 0x00, 0x07, 0x69, 0x6E, 0x74, 0x54,
|
||||||
|
0x65, 0x73, 0x74, 0x7F, 0xFF, 0xFF, 0xFF, 0x0A, 0x00, 0x14, 0x6E, 0x65, 0x73, 0x74, 0x65,
|
||||||
|
0x64, 0x20, 0x63, 0x6F, 0x6D, 0x70, 0x6F, 0x75, 0x6E, 0x64, 0x20, 0x74, 0x65, 0x73, 0x74,
|
||||||
|
0x0A, 0x00, 0x03, 0x68, 0x61, 0x6D, 0x08, 0x00, 0x04, 0x6E, 0x61, 0x6D, 0x65, 0x00, 0x06,
|
||||||
|
0x48, 0x61, 0x6D, 0x70, 0x75, 0x73, 0x05, 0x00, 0x05, 0x76, 0x61, 0x6C, 0x75, 0x65, 0x3F,
|
||||||
|
0x40, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x03, 0x65, 0x67, 0x67, 0x08, 0x00, 0x04, 0x6E, 0x61,
|
||||||
|
0x6D, 0x65, 0x00, 0x07, 0x45, 0x67, 0x67, 0x62, 0x65, 0x72, 0x74, 0x05, 0x00, 0x05, 0x76,
|
||||||
|
0x61, 0x6C, 0x75, 0x65, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x0F, 0x6C, 0x69,
|
||||||
|
0x73, 0x74, 0x54, 0x65, 0x73, 0x74, 0x20, 0x28, 0x6C, 0x6F, 0x6E, 0x67, 0x29, 0x04, 0x00,
|
||||||
|
0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x09, 0x00,
|
||||||
|
0x13, 0x6C, 0x69, 0x73, 0x74, 0x54, 0x65, 0x73, 0x74, 0x20, 0x28, 0x63, 0x6F, 0x6D, 0x70,
|
||||||
|
0x6F, 0x75, 0x6E, 0x64, 0x29, 0x0A, 0x00, 0x00, 0x00, 0x02, 0x08, 0x00, 0x04, 0x6E, 0x61,
|
||||||
|
0x6D, 0x65, 0x00, 0x0F, 0x43, 0x6F, 0x6D, 0x70, 0x6F, 0x75, 0x6E, 0x64, 0x20, 0x74, 0x61,
|
||||||
|
0x67, 0x20, 0x23, 0x30, 0x04, 0x00, 0x0A, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x2D,
|
||||||
|
0x6F, 0x6E, 0x00, 0x00, 0x01, 0x26, 0x52, 0x37, 0xD5, 0x8D, 0x00, 0x08, 0x00, 0x04, 0x6E,
|
||||||
|
0x61, 0x6D, 0x65, 0x00, 0x0F, 0x43, 0x6F, 0x6D, 0x70, 0x6F, 0x75, 0x6E, 0x64, 0x20, 0x74,
|
||||||
|
0x61, 0x67, 0x20, 0x23, 0x31, 0x04, 0x00, 0x0A, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64,
|
||||||
|
0x2D, 0x6F, 0x6E, 0x00, 0x00, 0x01, 0x26, 0x52, 0x37, 0xD5, 0x8D, 0x00, 0x01, 0x00, 0x08,
|
||||||
|
0x62, 0x79, 0x74, 0x65, 0x54, 0x65, 0x73, 0x74, 0x7F, 0x07, 0x00, 0x65, 0x62, 0x79, 0x74,
|
||||||
|
0x65, 0x41, 0x72, 0x72, 0x61, 0x79, 0x54, 0x65, 0x73, 0x74, 0x20, 0x28, 0x74, 0x68, 0x65,
|
||||||
|
0x20, 0x66, 0x69, 0x72, 0x73, 0x74, 0x20, 0x31, 0x30, 0x30, 0x30, 0x20, 0x76, 0x61, 0x6C,
|
||||||
|
0x75, 0x65, 0x73, 0x20, 0x6F, 0x66, 0x20, 0x28, 0x6E, 0x2A, 0x6E, 0x2A, 0x32, 0x35, 0x35,
|
||||||
|
0x2B, 0x6E, 0x2A, 0x37, 0x29, 0x25, 0x31, 0x30, 0x30, 0x2C, 0x20, 0x73, 0x74, 0x61, 0x72,
|
||||||
|
0x74, 0x69, 0x6E, 0x67, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x6E, 0x3D, 0x30, 0x20, 0x28,
|
||||||
|
0x30, 0x2C, 0x20, 0x36, 0x32, 0x2C, 0x20, 0x33, 0x34, 0x2C, 0x20, 0x31, 0x36, 0x2C, 0x20,
|
||||||
|
0x38, 0x2C, 0x20, 0x2E, 0x2E, 0x2E, 0x29, 0x29, 0x00, 0x00, 0x03, 0xE8, 0x00, 0x3E, 0x22,
|
||||||
|
0x10, 0x08, 0x0A, 0x16, 0x2C, 0x4C, 0x12, 0x46, 0x20, 0x04, 0x56, 0x4E, 0x50, 0x5C, 0x0E,
|
||||||
|
0x2E, 0x58, 0x28, 0x02, 0x4A, 0x38, 0x30, 0x32, 0x3E, 0x54, 0x10, 0x3A, 0x0A, 0x48, 0x2C,
|
||||||
|
0x1A, 0x12, 0x14, 0x20, 0x36, 0x56, 0x1C, 0x50, 0x2A, 0x0E, 0x60, 0x58, 0x5A, 0x02, 0x18,
|
||||||
|
0x38, 0x62, 0x32, 0x0C, 0x54, 0x42, 0x3A, 0x3C, 0x48, 0x5E, 0x1A, 0x44, 0x14, 0x52, 0x36,
|
||||||
|
0x24, 0x1C, 0x1E, 0x2A, 0x40, 0x60, 0x26, 0x5A, 0x34, 0x18, 0x06, 0x62, 0x00, 0x0C, 0x22,
|
||||||
|
0x42, 0x08, 0x3C, 0x16, 0x5E, 0x4C, 0x44, 0x46, 0x52, 0x04, 0x24, 0x4E, 0x1E, 0x5C, 0x40,
|
||||||
|
0x2E, 0x26, 0x28, 0x34, 0x4A, 0x06, 0x30, 0x00, 0x3E, 0x22, 0x10, 0x08, 0x0A, 0x16, 0x2C,
|
||||||
|
0x4C, 0x12, 0x46, 0x20, 0x04, 0x56, 0x4E, 0x50, 0x5C, 0x0E, 0x2E, 0x58, 0x28, 0x02, 0x4A,
|
||||||
|
0x38, 0x30, 0x32, 0x3E, 0x54, 0x10, 0x3A, 0x0A, 0x48, 0x2C, 0x1A, 0x12, 0x14, 0x20, 0x36,
|
||||||
|
0x56, 0x1C, 0x50, 0x2A, 0x0E, 0x60, 0x58, 0x5A, 0x02, 0x18, 0x38, 0x62, 0x32, 0x0C, 0x54,
|
||||||
|
0x42, 0x3A, 0x3C, 0x48, 0x5E, 0x1A, 0x44, 0x14, 0x52, 0x36, 0x24, 0x1C, 0x1E, 0x2A, 0x40,
|
||||||
|
0x60, 0x26, 0x5A, 0x34, 0x18, 0x06, 0x62, 0x00, 0x0C, 0x22, 0x42, 0x08, 0x3C, 0x16, 0x5E,
|
||||||
|
0x4C, 0x44, 0x46, 0x52, 0x04, 0x24, 0x4E, 0x1E, 0x5C, 0x40, 0x2E, 0x26, 0x28, 0x34, 0x4A,
|
||||||
|
0x06, 0x30, 0x00, 0x3E, 0x22, 0x10, 0x08, 0x0A, 0x16, 0x2C, 0x4C, 0x12, 0x46, 0x20, 0x04,
|
||||||
|
0x56, 0x4E, 0x50, 0x5C, 0x0E, 0x2E, 0x58, 0x28, 0x02, 0x4A, 0x38, 0x30, 0x32, 0x3E, 0x54,
|
||||||
|
0x10, 0x3A, 0x0A, 0x48, 0x2C, 0x1A, 0x12, 0x14, 0x20, 0x36, 0x56, 0x1C, 0x50, 0x2A, 0x0E,
|
||||||
|
0x60, 0x58, 0x5A, 0x02, 0x18, 0x38, 0x62, 0x32, 0x0C, 0x54, 0x42, 0x3A, 0x3C, 0x48, 0x5E,
|
||||||
|
0x1A, 0x44, 0x14, 0x52, 0x36, 0x24, 0x1C, 0x1E, 0x2A, 0x40, 0x60, 0x26, 0x5A, 0x34, 0x18,
|
||||||
|
0x06, 0x62, 0x00, 0x0C, 0x22, 0x42, 0x08, 0x3C, 0x16, 0x5E, 0x4C, 0x44, 0x46, 0x52, 0x04,
|
||||||
|
0x24, 0x4E, 0x1E, 0x5C, 0x40, 0x2E, 0x26, 0x28, 0x34, 0x4A, 0x06, 0x30, 0x00, 0x3E, 0x22,
|
||||||
|
0x10, 0x08, 0x0A, 0x16, 0x2C, 0x4C, 0x12, 0x46, 0x20, 0x04, 0x56, 0x4E, 0x50, 0x5C, 0x0E,
|
||||||
|
0x2E, 0x58, 0x28, 0x02, 0x4A, 0x38, 0x30, 0x32, 0x3E, 0x54, 0x10, 0x3A, 0x0A, 0x48, 0x2C,
|
||||||
|
0x1A, 0x12, 0x14, 0x20, 0x36, 0x56, 0x1C, 0x50, 0x2A, 0x0E, 0x60, 0x58, 0x5A, 0x02, 0x18,
|
||||||
|
0x38, 0x62, 0x32, 0x0C, 0x54, 0x42, 0x3A, 0x3C, 0x48, 0x5E, 0x1A, 0x44, 0x14, 0x52, 0x36,
|
||||||
|
0x24, 0x1C, 0x1E, 0x2A, 0x40, 0x60, 0x26, 0x5A, 0x34, 0x18, 0x06, 0x62, 0x00, 0x0C, 0x22,
|
||||||
|
0x42, 0x08, 0x3C, 0x16, 0x5E, 0x4C, 0x44, 0x46, 0x52, 0x04, 0x24, 0x4E, 0x1E, 0x5C, 0x40,
|
||||||
|
0x2E, 0x26, 0x28, 0x34, 0x4A, 0x06, 0x30, 0x00, 0x3E, 0x22, 0x10, 0x08, 0x0A, 0x16, 0x2C,
|
||||||
|
0x4C, 0x12, 0x46, 0x20, 0x04, 0x56, 0x4E, 0x50, 0x5C, 0x0E, 0x2E, 0x58, 0x28, 0x02, 0x4A,
|
||||||
|
0x38, 0x30, 0x32, 0x3E, 0x54, 0x10, 0x3A, 0x0A, 0x48, 0x2C, 0x1A, 0x12, 0x14, 0x20, 0x36,
|
||||||
|
0x56, 0x1C, 0x50, 0x2A, 0x0E, 0x60, 0x58, 0x5A, 0x02, 0x18, 0x38, 0x62, 0x32, 0x0C, 0x54,
|
||||||
|
0x42, 0x3A, 0x3C, 0x48, 0x5E, 0x1A, 0x44, 0x14, 0x52, 0x36, 0x24, 0x1C, 0x1E, 0x2A, 0x40,
|
||||||
|
0x60, 0x26, 0x5A, 0x34, 0x18, 0x06, 0x62, 0x00, 0x0C, 0x22, 0x42, 0x08, 0x3C, 0x16, 0x5E,
|
||||||
|
0x4C, 0x44, 0x46, 0x52, 0x04, 0x24, 0x4E, 0x1E, 0x5C, 0x40, 0x2E, 0x26, 0x28, 0x34, 0x4A,
|
||||||
|
0x06, 0x30, 0x00, 0x3E, 0x22, 0x10, 0x08, 0x0A, 0x16, 0x2C, 0x4C, 0x12, 0x46, 0x20, 0x04,
|
||||||
|
0x56, 0x4E, 0x50, 0x5C, 0x0E, 0x2E, 0x58, 0x28, 0x02, 0x4A, 0x38, 0x30, 0x32, 0x3E, 0x54,
|
||||||
|
0x10, 0x3A, 0x0A, 0x48, 0x2C, 0x1A, 0x12, 0x14, 0x20, 0x36, 0x56, 0x1C, 0x50, 0x2A, 0x0E,
|
||||||
|
0x60, 0x58, 0x5A, 0x02, 0x18, 0x38, 0x62, 0x32, 0x0C, 0x54, 0x42, 0x3A, 0x3C, 0x48, 0x5E,
|
||||||
|
0x1A, 0x44, 0x14, 0x52, 0x36, 0x24, 0x1C, 0x1E, 0x2A, 0x40, 0x60, 0x26, 0x5A, 0x34, 0x18,
|
||||||
|
0x06, 0x62, 0x00, 0x0C, 0x22, 0x42, 0x08, 0x3C, 0x16, 0x5E, 0x4C, 0x44, 0x46, 0x52, 0x04,
|
||||||
|
0x24, 0x4E, 0x1E, 0x5C, 0x40, 0x2E, 0x26, 0x28, 0x34, 0x4A, 0x06, 0x30, 0x00, 0x3E, 0x22,
|
||||||
|
0x10, 0x08, 0x0A, 0x16, 0x2C, 0x4C, 0x12, 0x46, 0x20, 0x04, 0x56, 0x4E, 0x50, 0x5C, 0x0E,
|
||||||
|
0x2E, 0x58, 0x28, 0x02, 0x4A, 0x38, 0x30, 0x32, 0x3E, 0x54, 0x10, 0x3A, 0x0A, 0x48, 0x2C,
|
||||||
|
0x1A, 0x12, 0x14, 0x20, 0x36, 0x56, 0x1C, 0x50, 0x2A, 0x0E, 0x60, 0x58, 0x5A, 0x02, 0x18,
|
||||||
|
0x38, 0x62, 0x32, 0x0C, 0x54, 0x42, 0x3A, 0x3C, 0x48, 0x5E, 0x1A, 0x44, 0x14, 0x52, 0x36,
|
||||||
|
0x24, 0x1C, 0x1E, 0x2A, 0x40, 0x60, 0x26, 0x5A, 0x34, 0x18, 0x06, 0x62, 0x00, 0x0C, 0x22,
|
||||||
|
0x42, 0x08, 0x3C, 0x16, 0x5E, 0x4C, 0x44, 0x46, 0x52, 0x04, 0x24, 0x4E, 0x1E, 0x5C, 0x40,
|
||||||
|
0x2E, 0x26, 0x28, 0x34, 0x4A, 0x06, 0x30, 0x00, 0x3E, 0x22, 0x10, 0x08, 0x0A, 0x16, 0x2C,
|
||||||
|
0x4C, 0x12, 0x46, 0x20, 0x04, 0x56, 0x4E, 0x50, 0x5C, 0x0E, 0x2E, 0x58, 0x28, 0x02, 0x4A,
|
||||||
|
0x38, 0x30, 0x32, 0x3E, 0x54, 0x10, 0x3A, 0x0A, 0x48, 0x2C, 0x1A, 0x12, 0x14, 0x20, 0x36,
|
||||||
|
0x56, 0x1C, 0x50, 0x2A, 0x0E, 0x60, 0x58, 0x5A, 0x02, 0x18, 0x38, 0x62, 0x32, 0x0C, 0x54,
|
||||||
|
0x42, 0x3A, 0x3C, 0x48, 0x5E, 0x1A, 0x44, 0x14, 0x52, 0x36, 0x24, 0x1C, 0x1E, 0x2A, 0x40,
|
||||||
|
0x60, 0x26, 0x5A, 0x34, 0x18, 0x06, 0x62, 0x00, 0x0C, 0x22, 0x42, 0x08, 0x3C, 0x16, 0x5E,
|
||||||
|
0x4C, 0x44, 0x46, 0x52, 0x04, 0x24, 0x4E, 0x1E, 0x5C, 0x40, 0x2E, 0x26, 0x28, 0x34, 0x4A,
|
||||||
|
0x06, 0x30, 0x00, 0x3E, 0x22, 0x10, 0x08, 0x0A, 0x16, 0x2C, 0x4C, 0x12, 0x46, 0x20, 0x04,
|
||||||
|
0x56, 0x4E, 0x50, 0x5C, 0x0E, 0x2E, 0x58, 0x28, 0x02, 0x4A, 0x38, 0x30, 0x32, 0x3E, 0x54,
|
||||||
|
0x10, 0x3A, 0x0A, 0x48, 0x2C, 0x1A, 0x12, 0x14, 0x20, 0x36, 0x56, 0x1C, 0x50, 0x2A, 0x0E,
|
||||||
|
0x60, 0x58, 0x5A, 0x02, 0x18, 0x38, 0x62, 0x32, 0x0C, 0x54, 0x42, 0x3A, 0x3C, 0x48, 0x5E,
|
||||||
|
0x1A, 0x44, 0x14, 0x52, 0x36, 0x24, 0x1C, 0x1E, 0x2A, 0x40, 0x60, 0x26, 0x5A, 0x34, 0x18,
|
||||||
|
0x06, 0x62, 0x00, 0x0C, 0x22, 0x42, 0x08, 0x3C, 0x16, 0x5E, 0x4C, 0x44, 0x46, 0x52, 0x04,
|
||||||
|
0x24, 0x4E, 0x1E, 0x5C, 0x40, 0x2E, 0x26, 0x28, 0x34, 0x4A, 0x06, 0x30, 0x00, 0x3E, 0x22,
|
||||||
|
0x10, 0x08, 0x0A, 0x16, 0x2C, 0x4C, 0x12, 0x46, 0x20, 0x04, 0x56, 0x4E, 0x50, 0x5C, 0x0E,
|
||||||
|
0x2E, 0x58, 0x28, 0x02, 0x4A, 0x38, 0x30, 0x32, 0x3E, 0x54, 0x10, 0x3A, 0x0A, 0x48, 0x2C,
|
||||||
|
0x1A, 0x12, 0x14, 0x20, 0x36, 0x56, 0x1C, 0x50, 0x2A, 0x0E, 0x60, 0x58, 0x5A, 0x02, 0x18,
|
||||||
|
0x38, 0x62, 0x32, 0x0C, 0x54, 0x42, 0x3A, 0x3C, 0x48, 0x5E, 0x1A, 0x44, 0x14, 0x52, 0x36,
|
||||||
|
0x24, 0x1C, 0x1E, 0x2A, 0x40, 0x60, 0x26, 0x5A, 0x34, 0x18, 0x06, 0x62, 0x00, 0x0C, 0x22,
|
||||||
|
0x42, 0x08, 0x3C, 0x16, 0x5E, 0x4C, 0x44, 0x46, 0x52, 0x04, 0x24, 0x4E, 0x1E, 0x5C, 0x40,
|
||||||
|
0x2E, 0x26, 0x28, 0x34, 0x4A, 0x06, 0x30, 0x06, 0x00, 0x0A, 0x64, 0x6F, 0x75, 0x62, 0x6C,
|
||||||
|
0x65, 0x54, 0x65, 0x73, 0x74, 0x3F, 0xDF, 0x8F, 0x6B, 0xBB, 0xFF, 0x6A, 0x5E, 0x00,
|
||||||
|
];
|
||||||
|
read_test(data.to_vec());
|
||||||
|
}
|
||||||
|
|
||||||
|
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 end_time = std::time::Instant::now();
|
||||||
|
println!("===local nbt===");
|
||||||
|
println!("time: {:?}", end_time - start_time);
|
||||||
|
println!("speed: {:?} (bytes/sec)", len as f64 / (end_time - start_time).as_secs_f64());
|
||||||
|
println!("{:?} (kb/sec)", len as f64 / (end_time - start_time).as_secs_f64() / 1024.0);
|
||||||
|
println!(
|
||||||
|
"{:?} (mb/sec)",
|
||||||
|
len as f64 / (end_time - start_time).as_secs_f64() / 1024.0 / 1024.0
|
||||||
|
);
|
||||||
|
// println!("{:?}", data);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user