Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ cbor4ii = { version = "=1.0.0", features = [
], optional = true }
ciborium = { version = "=0.2.2", optional = true }
columnar = { version = "=0.11", optional = true }
compactly = { version = "=0.1.6", optional = true }
databuf = { version = "=0.5.0", optional = true }
dlhn = { version = "=0.1.7", optional = true }
flatbuffers = { version = "=25.12.19", optional = true }
Expand Down Expand Up @@ -118,6 +119,7 @@ default-encoding-set = [
"cbor4ii",
"ciborium",
"columnar",
"compactly",
"databuf",
"dlhn",
"flatbuffers",
Expand Down
14 changes: 14 additions & 0 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ use rust_serialization_benchmark::bench_cbor4ii;
use rust_serialization_benchmark::bench_ciborium;
#[cfg(feature = "columnar")]
use rust_serialization_benchmark::bench_columnar;
#[cfg(feature = "compactly")]
use rust_serialization_benchmark::bench_compactly;
#[cfg(feature = "databuf")]
use rust_serialization_benchmark::bench_databuf;
#[cfg(feature = "dlhn")]
Expand Down Expand Up @@ -139,6 +141,9 @@ fn bench_log(c: &mut Criterion) {
#[cfg(feature = "columnar")]
bench_columnar::bench(BENCH, c, &data);

#[cfg(feature = "compactly")]
bench_compactly::bench(BENCH, c, &data);

#[cfg(feature = "databuf")]
bench_databuf::bench_borrowable(BENCH, c, &data);

Expand Down Expand Up @@ -365,6 +370,9 @@ fn bench_mesh(c: &mut Criterion) {
#[cfg(feature = "columnar")]
bench_columnar::bench(BENCH, c, &data);

#[cfg(feature = "compactly")]
bench_compactly::bench(BENCH, c, &data);

#[cfg(feature = "databuf")]
bench_databuf::bench(BENCH, c, &data);

Expand Down Expand Up @@ -575,6 +583,9 @@ fn bench_minecraft_savedata(c: &mut Criterion) {
#[cfg(feature = "columnar")]
bench_columnar::bench(BENCH, c, &data);

#[cfg(feature = "compactly")]
bench_compactly::bench(BENCH, c, &data);

#[cfg(feature = "databuf")]
bench_databuf::bench_borrowable(BENCH, c, &data);

Expand Down Expand Up @@ -795,6 +806,9 @@ fn bench_mk48(c: &mut Criterion) {
#[cfg(feature = "columnar")]
bench_columnar::bench(BENCH, c, &data);

#[cfg(feature = "compactly")]
bench_compactly::bench(BENCH, c, &data);

#[cfg(feature = "databuf")]
bench_databuf::bench(BENCH, c, &data);

Expand Down
29 changes: 29 additions & 0 deletions src/bench_compactly.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use compactly::{Encode};

Check warning on line 1 in src/bench_compactly.rs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Diff in /home/runner/work/rust_serialization_benchmark/rust_serialization_benchmark/src/bench_compactly.rs
use criterion::{black_box, Criterion};

pub fn bench<T>(name: &'static str, c: &mut Criterion, data: &T)
where
T: Encode + PartialEq,
{

Check warning on line 7 in src/bench_compactly.rs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Diff in /home/runner/work/rust_serialization_benchmark/rust_serialization_benchmark/src/bench_compactly.rs
let mut group = c.benchmark_group(format!("{}/compactly", name));

group.bench_function("serialize", |b| {
b.iter(|| {
black_box(compactly::v2::Ans::encode(black_box(data)));
})
});

let encoded = compactly::v2::Ans::encode(data).to_vec();

group.bench_function("deserialize", |b| {
b.iter(|| {
black_box(compactly::v2::Ans::decode::<T>(black_box(&encoded)).unwrap());
})
});

crate::bench_size(name, "compactly", &encoded);

assert!(compactly::v2::Ans::decode::<T>(&encoded).unwrap() == *data);

group.finish();
}
3 changes: 3 additions & 0 deletions src/datasets/log/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ use crate::Generate;
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -236,6 +237,7 @@ impl From<log_protobuf::log::Address> for Address {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -525,6 +527,7 @@ impl From<log_protobuf::log::Log> for Log {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down
3 changes: 3 additions & 0 deletions src/datasets/mesh/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ use crate::Generate;
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -175,6 +176,7 @@ impl From<mesh_protobuf::mesh::Vector3> for Vector3 {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -321,6 +323,7 @@ impl From<mesh_protobuf::mesh::Triangle> for Triangle {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down
7 changes: 7 additions & 0 deletions src/datasets/minecraft_savedata/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ use crate::{generate_vec, Generate};
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -205,6 +206,7 @@ impl From<rpb::minecraft_savedata::GameType> for GameType {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -406,6 +408,7 @@ impl From<rpb::minecraft_savedata::Item> for Item {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -578,6 +581,7 @@ impl From<rpb::minecraft_savedata::Abilities> for Abilities {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -1048,6 +1052,7 @@ impl From<rpb::minecraft_savedata::Entity> for Entity {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -1384,6 +1389,7 @@ impl From<rpb::minecraft_savedata::RecipeBook> for RecipeBook {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -2087,6 +2093,7 @@ impl From<rpb::minecraft_savedata::Player> for Player {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down
7 changes: 7 additions & 0 deletions src/datasets/mk48/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ use crate::{generate_vec, Generate};
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -351,6 +352,7 @@ fn generate_velocity(rng: &mut impl Rng) -> i16 {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -520,6 +522,7 @@ impl From<rpb::mk48::Transform> for Transform {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -652,6 +655,7 @@ impl From<rpb::mk48::Guidance> for Guidance {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -922,6 +926,7 @@ impl From<rpb::mk48::Contact> for Contact {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -1094,6 +1099,7 @@ impl From<rpb::mk48::TerrainUpdate> for TerrainUpdate {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -1278,6 +1284,7 @@ impl From<rpb::mk48::Update> for Update {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ pub mod bench_cbor4ii;
pub mod bench_ciborium;
#[cfg(feature = "columnar")]
pub mod bench_columnar;
#[cfg(feature = "compactly")]
pub mod bench_compactly;
#[cfg(feature = "databuf")]
pub mod bench_databuf;
#[cfg(feature = "dlhn")]
Expand Down
Loading