Skip to content

Commit

Permalink
attempt of fury
Browse files Browse the repository at this point in the history
  • Loading branch information
ozkanpakdil committed Sep 15, 2024
1 parent f83a991 commit 1a24642
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ borsh = { version = "=1.5.1", features = ["derive"], optional = true }
# https://github.com/mongodb/bson-rust/pull/328
bson = { version = "=2.9.0", git = "https://github.com/djkoloski/bson-rust", branch = "add_into_vec", optional = true }
bytecheck = { version = "=0.6.12", optional = true }
bytemuck = { version = "=1.16.1", optional = true }
bytemuck = { version = "=1.18.0", optional = true }
capnp = { version = "=0.19.6", optional = true }
cbor4ii = { version = "=0.3.2", features = [ "use_std", "serde1" ], optional = true }
ciborium = { version = "=0.2.2", optional = true }
Expand Down Expand Up @@ -93,6 +93,7 @@ savefile = { version = "=0.17.6", optional = true }
savefile-derive = { version = "=0.17.6", optional = true }
wiring = { version = "=0.2.1", optional = true }
zstd = "=0.13.2"
fury = { git= "https://github.com/apache/incubator-fury.git", branch = "main" }

[features]
default = [
Expand Down
35 changes: 35 additions & 0 deletions src/bench_fury.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use criterion::{black_box, Criterion};
use serde::{Deserialize, Serialize};
use fury::{Fury};

pub fn bench<T>(name: &'static str, c: &mut Criterion, data: &T)
where
T: Serialize + for<'de> Deserialize<'de> + PartialEq,
{
const BUFFER_LEN: usize = 50_000_000;

let mut group = c.benchmark_group(format!("{}/fury", name));

let mut serialize_buffer = vec![0; BUFFER_LEN];
group.bench_function("serialize", |b| {
b.iter(|| {
Fury::serialize(black_box(serialize_buffer.as_mut_slice()), black_box(&data));
black_box(());
})
});

let mut deserialize_buffer = Vec::new();
Fury::serialize(&mut deserialize_buffer, &data);

group.bench_function("deserialize", |b| {
b.iter(|| {
black_box(serde_json::from_slice::<'_, T>(black_box(&deserialize_buffer)).unwrap());
})
});

crate::bench_size(name, "fury", deserialize_buffer.as_slice());

assert!(Fury::deserialize()::<T>(&deserialize_buffer).unwrap() == *data);

group.finish();
}

0 comments on commit 1a24642

Please sign in to comment.