-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: Improve doc comments * Minor cleanup, fix of benchmark * Fix failing test for new rustc
- Loading branch information
Showing
14 changed files
with
40 additions
and
168 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "savefile-abi" | ||
version = "0.17.1" | ||
version = "0.17.2" | ||
edition = "2021" | ||
authors = ["Anders Musikka <[email protected]>"] | ||
documentation = "https://docs.rs/savefile-abi/" | ||
|
@@ -16,7 +16,7 @@ keywords = ["dylib", "dlopen", "ffi"] | |
license = "MIT/Apache-2.0" | ||
|
||
[dependencies] | ||
savefile = { path="../savefile", version = "=0.17.1" } | ||
savefile-derive = { path="../savefile-derive", version = "=0.17.1" } | ||
savefile = { path="../savefile", version = "=0.17.2" } | ||
savefile-derive = { path="../savefile-derive", version = "=0.17.2" } | ||
byteorder = "1.4" | ||
libloading = "0.8" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "savefile-derive" | ||
version = "0.17.1" | ||
version = "0.17.2" | ||
authors = ["Anders Musikka <[email protected]>"] | ||
|
||
description = "Custom derive macros for savefile crate - simple, convenient, fast, versioned, binary serialization/deserialization library." | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,131 +1,14 @@ | ||
/*#![allow(soft_unstable)] | ||
#![feature(test)] | ||
extern crate alkahest; | ||
extern crate test; | ||
use std::hint::black_box; | ||
use test::Bencher; | ||
|
||
use savefile_derive::Savefile; | ||
use savefile::Packed; | ||
|
||
#[derive(Clone, Copy, Debug, PartialEq,Default)] | ||
#[derive(alkahest::Schema)] | ||
#[derive(Savefile)] | ||
pub struct Vector3 { | ||
pub x: f32, | ||
pub y: f32, | ||
pub z: f32, | ||
} | ||
|
||
impl alkahest::Pack<Vector3> for Vector3 { | ||
#[inline] | ||
fn pack(self, offset: usize, output: &mut [u8]) -> (alkahest::Packed<Self>, usize) { | ||
Vector3Pack { | ||
x: self.x, | ||
y: self.y, | ||
z: self.z, | ||
} | ||
.pack(offset, output) | ||
} | ||
} | ||
#[derive(Clone, Copy, Debug, PartialEq,Default)] | ||
#[derive(alkahest::Schema)] | ||
#[derive(Savefile)] | ||
pub struct Triangle { | ||
pub v0: Vector3, | ||
pub v1: Vector3, | ||
pub v2: Vector3, | ||
pub normal: Vector3, | ||
} | ||
impl alkahest::Pack<Triangle> for &'_ Triangle { | ||
#[inline] | ||
fn pack(self, offset: usize, output: &mut [u8]) -> (alkahest::Packed<Triangle>, usize) { | ||
TrianglePack { | ||
v0: self.v0, | ||
v1: self.v1, | ||
v2: self.v2, | ||
normal: self.normal, | ||
} | ||
.pack(offset, output) | ||
} | ||
#[derive(Debug, Savefile, PartialEq)] | ||
pub enum TestStructEnum { | ||
Variant2 { a: u8, b: u8 }, | ||
} | ||
#[derive(Clone, Debug, PartialEq,Default)] | ||
#[derive(Savefile)] | ||
pub struct Mesh { | ||
pub triangles: Vec<Triangle>, | ||
} | ||
#[derive(alkahest::Schema)] | ||
pub struct MeshSchema { | ||
pub triangles: alkahest::Seq<Triangle>, | ||
} | ||
impl alkahest::Pack<MeshSchema> for &'_ Mesh { | ||
#[inline] | ||
fn pack(self, offset: usize, output: &mut [u8]) -> (alkahest::Packed<MeshSchema>, usize) { | ||
MeshSchemaPack { | ||
triangles: self.triangles.iter(), | ||
} | ||
.pack(offset, output) | ||
} | ||
} | ||
pub fn generate_mesh() -> Mesh { | ||
|
||
let mut mesh = Mesh { | ||
triangles: vec![] | ||
}; | ||
const TRIANGLES: usize = 125_000; | ||
for _ in 0..TRIANGLES { | ||
mesh.triangles.push(Triangle::default()) | ||
} | ||
mesh | ||
} | ||
#[bench] | ||
fn bench_alkahest(b: &mut Bencher) { | ||
const BUFFER_LEN: usize = 10_000_000; | ||
let mesh = generate_mesh(); | ||
let mut buffer = vec![0; BUFFER_LEN]; | ||
b.iter(move || { | ||
alkahest::write::<MeshSchema, _>(black_box(&mut buffer), black_box(&mesh)); | ||
}); | ||
} | ||
#[bench] | ||
fn bench_savefile(b: &mut Bencher) { | ||
let mesh = generate_mesh(); | ||
let mut encoded: Vec<u8> = Vec::with_capacity(10_000_000); | ||
assert!(unsafe { Triangle::repr_c_optimization_safe(0).is_yes() } ); | ||
b.iter(move || { | ||
/*let l = mesh.triangles.len(); | ||
let data_ptr = mesh.triangles.as_ptr() as *const u8; | ||
let data_len = l * std::mem::size_of::<Triangle>(); | ||
encoded | ||
serializer.write_buf(std::slice::from_raw_parts( | ||
self.as_ptr() as *const u8, | ||
std::mem::size_of::<T>() * l, | ||
))*/ | ||
encoded.clear(); | ||
#[test] | ||
fn test() { | ||
|
||
savefile::save_noschema(black_box(&mut encoded), 0, black_box(&mesh)).unwrap(); | ||
}) | ||
} | ||
|
||
/* | ||
fn stuff<T>() -> T { | ||
todo!() | ||
} | ||
*/ | ||
#[test] | ||
fn dummy() { | ||
}*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "savefile" | ||
version = "0.17.1" | ||
version = "0.17.2" | ||
authors = ["Anders Musikka <[email protected]>"] | ||
documentation = "https://docs.rs/savefile/" | ||
homepage = "https://github.com/avl/savefile/" | ||
|
@@ -54,13 +54,13 @@ bit-set = {version = "0.5", optional = true} | |
rustc-hash = {version = "1.1", optional = true} | ||
memoffset = "0.9" | ||
byteorder = "1.4" | ||
savefile-derive = {path="../savefile-derive", version = "=0.17.1", optional = true } | ||
savefile-derive = {path="../savefile-derive", version = "=0.17.2", optional = true } | ||
serde_derive = {version= "1.0", optional = true} | ||
serde = {version= "1.0", optional = true} | ||
quickcheck = {version= "1.0", optional = true} | ||
|
||
[dev-dependencies] | ||
savefile-derive = { path="../savefile-derive", version = "=0.17.1" } | ||
savefile-derive = { path="../savefile-derive", version = "=0.17.2" } | ||
|
||
[build-dependencies] | ||
rustc_version="0.2" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters