重构目录结构
This commit is contained in:
parent
618dd911c5
commit
f0632bb09a
52
.vscode/settings.json
vendored
52
.vscode/settings.json
vendored
@ -1,9 +1,47 @@
|
||||
{
|
||||
"rust-analyzer.linkedProjects": [
|
||||
"crates/shen-nbt1/Cargo.toml",
|
||||
"crates/shen-nbt2/Cargo.toml",
|
||||
"crates/shen-nbt3/Cargo.toml",
|
||||
"crates/shen-nbt4/Cargo.toml",
|
||||
"crates/nbt-test/Cargo.toml",
|
||||
]
|
||||
"files.associations": {
|
||||
"*.html": "html",
|
||||
"__bit_reference": "cpp",
|
||||
"__config": "cpp",
|
||||
"__hash_table": "cpp",
|
||||
"__locale": "cpp",
|
||||
"__node_handle": "cpp",
|
||||
"__split_buffer": "cpp",
|
||||
"__threading_support": "cpp",
|
||||
"__verbose_abort": "cpp",
|
||||
"array": "cpp",
|
||||
"cctype": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cstring": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"execution": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"ios": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"limits": "cpp",
|
||||
"locale": "cpp",
|
||||
"mutex": "cpp",
|
||||
"new": "cpp",
|
||||
"optional": "cpp",
|
||||
"ratio": "cpp",
|
||||
"span": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"string": "cpp",
|
||||
"string_view": "cpp",
|
||||
"tuple": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"variant": "cpp",
|
||||
"vector": "cpp",
|
||||
"algorithm": "cpp"
|
||||
}
|
||||
}
|
10
Cargo.toml
Normal file
10
Cargo.toml
Normal file
@ -0,0 +1,10 @@
|
||||
[workspace]
|
||||
members = [
|
||||
"nbt-test",
|
||||
# "shen-nbt1", # EOL!
|
||||
"shen-nbt2",
|
||||
"shen-nbt3",
|
||||
"shen-nbt4",
|
||||
"shen-nbt5",
|
||||
]
|
||||
resolver = "2"
|
@ -192,7 +192,6 @@ fn test_fastnbt(data: Vec<u8>) {
|
||||
}
|
||||
|
||||
fn read_test(in_data: Vec<u8>) {
|
||||
let len = in_data.len();
|
||||
#[cfg(feature = "debug")]
|
||||
println!("data: {:?}", data);
|
||||
|
||||
@ -219,44 +218,65 @@ fn cli_read_test() {
|
||||
let mut args = std::env::args();
|
||||
// 如果有, 取出
|
||||
if let Some(arg) = args.nth(1) {
|
||||
let data = std::fs::read(&arg).unwrap();
|
||||
let read_data = std::fs::read(&arg).unwrap();
|
||||
// read_test(data);
|
||||
let len = data.len();
|
||||
test_lib!(
|
||||
{
|
||||
let cursor: shen_nbt1::data::Reader = std::io::Cursor::new(data.as_slice());
|
||||
let nbt_data = shen_nbt1::data::NbtItem::try_from(cursor).unwrap();
|
||||
let len = read_data.len();
|
||||
let data = read_data;
|
||||
|
||||
std::thread::sleep(std::time::Duration::from_secs(1));
|
||||
let start_time = std::time::Instant::now();
|
||||
let nbt_data = shen_nbt4::Value::from_vec(data);
|
||||
let end_time = std::time::Instant::now();
|
||||
println!("=== shen nbt 4 ===");
|
||||
print!("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!(
|
||||
"{:?} (gb/sec)",
|
||||
len as f64 / (end_time - start_time).as_secs_f64() / 1024.0 / 1024.0 / 1024.0
|
||||
);
|
||||
#[cfg(feature = "core_debug")]
|
||||
println!("nbt_data: {:#?}", nbt_data);
|
||||
println!("nbt len {}", nbt_data.as_byte().is_some());
|
||||
// test_lib!(
|
||||
// {
|
||||
// let cursor: shen_nbt1::data::Reader = std::io::Cursor::new(data.as_slice());
|
||||
// let nbt_data = shen_nbt1::data::NbtItem::try_from(cursor).unwrap();
|
||||
|
||||
}, "nbt v1", len
|
||||
);
|
||||
// }, "nbt v1", len
|
||||
// );
|
||||
|
||||
let data2 = std::fs::read(&arg).unwrap();
|
||||
test_lib!(
|
||||
{
|
||||
let nbt_data = shen_nbt2::Value::from_vec(data2);
|
||||
}, "nbt v2", len
|
||||
);
|
||||
// let data2 = std::fs::read(&arg).unwrap();
|
||||
// test_lib!(
|
||||
// {
|
||||
// let nbt_data = shen_nbt2::Value::from_vec(data2);
|
||||
// }, "nbt v2", len
|
||||
// );
|
||||
|
||||
let data3 = std::fs::read(&arg).unwrap();
|
||||
test_lib!(
|
||||
{
|
||||
let nbt_data = shen_nbt3::Value::from_vec(data3);
|
||||
}, "nbt v3", len
|
||||
);
|
||||
// let data3 = std::fs::read(&arg).unwrap();
|
||||
// test_lib!(
|
||||
// {
|
||||
// let nbt_data = shen_nbt3::Value::from_vec(data3);
|
||||
// }, "nbt v3", len
|
||||
// );
|
||||
|
||||
let data4 = std::fs::read(&arg).unwrap();
|
||||
test_lib!(
|
||||
{
|
||||
let nbt_data = shen_nbt4::Value::from_vec(data4);
|
||||
}, "nbt v4", len
|
||||
);
|
||||
// let data4 = std::fs::read(&arg).unwrap();
|
||||
// test_lib!(
|
||||
// {
|
||||
// let nbt_data = shen_nbt4::Value::from_vec(data);
|
||||
// }, "nbt v4", len
|
||||
// );
|
||||
|
||||
let data5 = std::fs::read(&arg).unwrap();
|
||||
test_lib!(
|
||||
{
|
||||
let nbt_data: fastnbt::Value = fastnbt::from_bytes(data5.as_slice()).unwrap();
|
||||
}, "fastnbt", len
|
||||
);
|
||||
// let data5 = std::fs::read(&arg).unwrap();
|
||||
// test_lib!(
|
||||
// {
|
||||
// let nbt_data: fastnbt::Value = fastnbt::from_bytes(data5.as_slice()).unwrap();
|
||||
// }, "fastnbt", len
|
||||
// );
|
||||
} else {
|
||||
println!("Usage: cargo run --release -- <file>");
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
use crate::data::{NbtItem, NbtList, NbtValue, Reader};
|
||||
use std::convert::From;
|
||||
use std::io::{BufRead, Cursor, Read};
|
||||
|
||||
/// 输出类型标识符
|
8
shen-nbt5/Cargo.toml
Normal file
8
shen-nbt5/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "shen-nbt5"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
shen-nbt5/src/main.rs
Normal file
3
shen-nbt5/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
Loading…
Reference in New Issue
Block a user