Skip to content

Commit

Permalink
Format, alphabetize bench, remove unsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
djkoloski committed Jul 13, 2023
1 parent 32e1a58 commit c4ecc07
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 26 deletions.
30 changes: 15 additions & 15 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand All @@ -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};
Expand Down Expand Up @@ -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);

Expand All @@ -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) {
Expand Down Expand Up @@ -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);

Expand All @@ -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) {
Expand Down Expand Up @@ -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);

Expand All @@ -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) {
Expand Down Expand Up @@ -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);

Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/bench_savefile.rs
Original file line number Diff line number Diff line change
@@ -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<T>(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));

Expand Down
1 change: 0 additions & 1 deletion src/datasets/log/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,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,
Expand Down
4 changes: 2 additions & 2 deletions src/datasets/mesh/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -141,7 +141,7 @@ impl alkahest::Pack<Vector3> 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,
Expand Down
3 changes: 1 addition & 2 deletions src/datasets/minecraft_savedata/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions src/datasets/mk48/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand All @@ -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};
Expand Down

0 comments on commit c4ecc07

Please sign in to comment.