-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added bincode 2 as own benchmark * All bincode2 benchmarks running * Add support for multiple versions of a package --------- Co-authored-by: 8192K <sebastian@frehmel.de> Co-authored-by: David Koloski <djkoloski@gmail.com>
- Loading branch information
1 parent
e1f6a31
commit 7e8543c
Showing
19 changed files
with
217 additions
and
89 deletions.
There are no files selected for viewing
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
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,33 +1,36 @@ | ||
use criterion::{black_box, Criterion}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
pub fn bench<T>(name: &'static str, c: &mut Criterion, data: &T) | ||
where | ||
T: Serialize + for<'de> Deserialize<'de>, | ||
T: bincode::Encode + bincode::Decode, | ||
{ | ||
const BUFFER_LEN: usize = 10_000_000; | ||
|
||
let mut group = c.benchmark_group(format!("{}/bincode", name)); | ||
|
||
let mut serialize_buffer = vec![0; BUFFER_LEN]; | ||
let mut buffer = Box::new([0u8; BUFFER_LEN]); | ||
let conf = bincode::config::standard(); | ||
group.bench_function("serialize", |b| { | ||
b.iter(|| { | ||
bincode::serialize_into(black_box(serialize_buffer.as_mut_slice()), black_box(&data)) | ||
let size = bincode::encode_into_slice(black_box(&data), black_box(&mut *buffer), conf) | ||
.unwrap(); | ||
black_box(()); | ||
black_box(&buffer[..size]); | ||
}) | ||
}); | ||
|
||
let mut deserialize_buffer = Vec::new(); | ||
bincode::serialize_into(&mut deserialize_buffer, &data).unwrap(); | ||
let size = bincode::encode_into_slice(&data, &mut *buffer, conf).unwrap(); | ||
let buffer = &buffer[..size]; | ||
|
||
group.bench_function("deserialize", |b| { | ||
b.iter(|| { | ||
black_box(bincode::deserialize::<'_, T>(black_box(&deserialize_buffer)).unwrap()); | ||
black_box( | ||
bincode::decode_from_slice::<T, _>(black_box(buffer), conf) | ||
.unwrap() | ||
.0, | ||
); | ||
}) | ||
}); | ||
|
||
crate::bench_size(name, "bincode", deserialize_buffer.as_slice()); | ||
crate::bench_size(name, "bincode", buffer); | ||
|
||
group.finish(); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use criterion::{black_box, Criterion}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
pub fn bench<T>(name: &'static str, c: &mut Criterion, data: &T) | ||
where | ||
T: Serialize + for<'de> Deserialize<'de>, | ||
{ | ||
const BUFFER_LEN: usize = 10_000_000; | ||
|
||
let mut group = c.benchmark_group(format!("{}/bincode1", name)); | ||
|
||
let mut serialize_buffer = vec![0; BUFFER_LEN]; | ||
group.bench_function("serialize", |b| { | ||
b.iter(|| { | ||
bincode1::serialize_into(black_box(serialize_buffer.as_mut_slice()), black_box(&data)) | ||
.unwrap(); | ||
black_box(()); | ||
}) | ||
}); | ||
|
||
let mut deserialize_buffer = Vec::new(); | ||
bincode1::serialize_into(&mut deserialize_buffer, &data).unwrap(); | ||
|
||
group.bench_function("deserialize", |b| { | ||
b.iter(|| { | ||
black_box(bincode1::deserialize::<'_, T>(black_box(&deserialize_buffer)).unwrap()); | ||
}) | ||
}); | ||
|
||
crate::bench_size(name, "bincode1", deserialize_buffer.as_slice()); | ||
|
||
group.finish(); | ||
} |
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
Oops, something went wrong.