diff --git a/benches/bench.rs b/benches/bench.rs index 4c18102..14be5d7 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -36,6 +36,8 @@ use rust_serialization_benchmark::bench_rkyv; use rust_serialization_benchmark::bench_rmp_serde; #[cfg(feature = "ron")] use rust_serialization_benchmark::bench_ron; +#[cfg(feature = "savefile")] +use rust_serialization_benchmark::bench_savefile; #[cfg(feature = "serde_bare")] use rust_serialization_benchmark::bench_serde_bare; #[cfg(feature = "serde_cbor")] @@ -46,9 +48,7 @@ use rust_serialization_benchmark::bench_serde_json; use rust_serialization_benchmark::bench_simd_json; #[cfg(feature = "speedy")] use rust_serialization_benchmark::bench_speedy; -#[cfg(feature = "savefile")] -use rust_serialization_benchmark::bench_savefile; -use rust_serialization_benchmark::{generate_vec}; +use rust_serialization_benchmark::generate_vec; fn bench_log(c: &mut Criterion) { use rust_serialization_benchmark::datasets::log::{Log, Logs}; @@ -194,6 +194,9 @@ fn bench_log(c: &mut Criterion) { #[cfg(feature = "ron")] bench_ron::bench(BENCH, c, &data); + #[cfg(feature = "savefile")] + bench_savefile::bench(BENCH, c, &data); + #[cfg(feature = "serde_bare")] bench_serde_bare::bench(BENCH, c, &data); @@ -208,9 +211,6 @@ fn bench_log(c: &mut Criterion) { #[cfg(feature = "speedy")] bench_speedy::bench(BENCH, c, &data); - - #[cfg(feature = "savefile")] - bench_savefile::bench(BENCH, c, &data); } fn bench_mesh(c: &mut Criterion) { @@ -338,6 +338,9 @@ fn bench_mesh(c: &mut Criterion) { #[cfg(feature = "ron")] bench_ron::bench(BENCH, c, &data); + #[cfg(feature = "savefile")] + bench_savefile::bench(BENCH, c, &data); + #[cfg(feature = "serde_bare")] bench_serde_bare::bench(BENCH, c, &data); @@ -352,9 +355,6 @@ fn bench_mesh(c: &mut Criterion) { #[cfg(feature = "speedy")] bench_speedy::bench(BENCH, c, &data); - - #[cfg(feature = "savefile")] - bench_savefile::bench(BENCH, c, &data); } fn bench_minecraft_savedata(c: &mut Criterion) { @@ -485,6 +485,9 @@ fn bench_minecraft_savedata(c: &mut Criterion) { #[cfg(feature = "ron")] bench_ron::bench(BENCH, c, &data); + #[cfg(feature = "savefile")] + bench_savefile::bench(BENCH, c, &data); + #[cfg(feature = "serde_bare")] bench_serde_bare::bench(BENCH, c, &data); @@ -499,9 +502,6 @@ fn bench_minecraft_savedata(c: &mut Criterion) { #[cfg(feature = "speedy")] bench_speedy::bench(BENCH, c, &data); - - #[cfg(feature = "savefile")] - bench_savefile::bench(BENCH, c, &data); } fn bench_mk48(c: &mut Criterion) { @@ -628,6 +628,9 @@ fn bench_mk48(c: &mut Criterion) { #[cfg(feature = "ron")] bench_ron::bench(BENCH, c, &data); + #[cfg(feature = "savefile")] + bench_savefile::bench(BENCH, c, &data); + #[cfg(feature = "serde_bare")] bench_serde_bare::bench(BENCH, c, &data); @@ -642,9 +645,6 @@ fn bench_mk48(c: &mut Criterion) { #[cfg(feature = "speedy")] bench_speedy::bench(BENCH, c, &data); - - #[cfg(feature = "savefile")] - bench_savefile::bench(BENCH, c, &data); } pub fn criterion_benchmark(c: &mut Criterion) { diff --git a/src/bench_savefile.rs b/src/bench_savefile.rs index a11f843..86e7381 100644 --- a/src/bench_savefile.rs +++ b/src/bench_savefile.rs @@ -1,10 +1,10 @@ -use std::io::Cursor; use criterion::{black_box, Criterion}; use savefile::{Deserialize, Serialize, WithSchema}; +use std::io::Cursor; pub fn bench(name: &'static str, c: &mut Criterion, data: &T) where - T: Serialize + Deserialize + WithSchema + T: Serialize + Deserialize + WithSchema, { let mut group = c.benchmark_group(format!("{}/savefile", name)); diff --git a/src/datasets/log/mod.rs b/src/datasets/log/mod.rs index fe2a881..c79b4c0 100644 --- a/src/datasets/log/mod.rs +++ b/src/datasets/log/mod.rs @@ -42,6 +42,7 @@ use crate::Generate; derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] #[cfg_attr(feature = "rkyv", archive_attr(derive(bytecheck::CheckBytes)))] +#[cfg_attr(feature = "savefile", derive(savefile_derive::Savefile))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr( feature = "simd-json", @@ -53,7 +54,6 @@ use crate::Generate; )] #[cfg_attr(feature = "speedy", derive(speedy::Readable, speedy::Writable))] #[cfg_attr(feature = "alkahest", derive(alkahest::Schema))] -#[cfg_attr(feature = "savefile", derive(savefile_derive::Savefile), savefile_unsafe_and_fast, repr(C))] pub struct Address { pub x0: u8, pub x1: u8, diff --git a/src/datasets/mesh/mod.rs b/src/datasets/mesh/mod.rs index dd69295..b637ec1 100644 --- a/src/datasets/mesh/mod.rs +++ b/src/datasets/mesh/mod.rs @@ -52,7 +52,7 @@ use crate::Generate; )] #[cfg_attr(feature = "speedy", derive(speedy::Readable, speedy::Writable))] #[cfg_attr(feature = "alkahest", derive(alkahest::Schema))] -#[cfg_attr(feature = "savefile", derive(savefile_derive::Savefile), savefile_unsafe_and_fast, repr(C))] +#[cfg_attr(feature = "savefile", derive(savefile_derive::Savefile))] pub struct Vector3 { pub x: f32, pub y: f32, @@ -141,7 +141,7 @@ impl alkahest::Pack for Vector3 { )] #[cfg_attr(feature = "speedy", derive(speedy::Readable, speedy::Writable))] #[cfg_attr(feature = "alkahest", derive(alkahest::Schema))] -#[cfg_attr(feature = "savefile", derive(savefile_derive::Savefile), savefile_unsafe_and_fast, repr(C))] +#[cfg_attr(feature = "savefile", derive(savefile_derive::Savefile))] pub struct Triangle { pub v0: Vector3, pub v1: Vector3, diff --git a/src/datasets/minecraft_savedata/mod.rs b/src/datasets/minecraft_savedata/mod.rs index f770b33..8fcf77b 100644 --- a/src/datasets/minecraft_savedata/mod.rs +++ b/src/datasets/minecraft_savedata/mod.rs @@ -53,8 +53,7 @@ use crate::{generate_vec, Generate}; )] #[cfg_attr(feature = "speedy", derive(speedy::Readable, speedy::Writable))] #[cfg_attr(feature = "alkahest", derive(alkahest::Schema))] -#[cfg_attr(feature = "savefile", derive(savefile_derive::Savefile), savefile_unsafe_and_fast)] -#[repr(u8)] +#[cfg_attr(feature = "savefile", derive(savefile_derive::Savefile))] pub enum GameType { Survival, Creative, diff --git a/src/datasets/mk48/mod.rs b/src/datasets/mk48/mod.rs index 8b1e708..75be3da 100644 --- a/src/datasets/mk48/mod.rs +++ b/src/datasets/mk48/mod.rs @@ -55,8 +55,7 @@ use crate::{generate_vec, Generate}; )] #[cfg_attr(feature = "speedy", derive(speedy::Readable, speedy::Writable))] #[cfg_attr(feature = "alkahest", derive(alkahest::Schema))] -#[cfg_attr(feature = "savefile", derive(savefile_derive::Savefile), savefile_unsafe_and_fast)] -#[repr(u8)] +#[cfg_attr(feature = "savefile", derive(savefile_derive::Savefile))] pub enum EntityType { #[cfg_attr(feature = "bitcode", bitcode_hint(frequency = 2.14))] ArleighBurke, diff --git a/src/lib.rs b/src/lib.rs index 62919d6..4efa1a9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -34,6 +34,8 @@ pub mod bench_rkyv; pub mod bench_rmp_serde; #[cfg(feature = "ron")] pub mod bench_ron; +#[cfg(feature = "savefile")] +pub mod bench_savefile; #[cfg(feature = "serde_bare")] pub mod bench_serde_bare; #[cfg(feature = "serde_cbor")] @@ -44,8 +46,6 @@ pub mod bench_serde_json; pub mod bench_simd_json; #[cfg(feature = "speedy")] pub mod bench_speedy; -#[cfg(feature = "savefile")] -pub mod bench_savefile; pub mod datasets; use core::{mem, ops};