From d4d537439299a8f6bec1f23fbd2c081b68a51e91 Mon Sep 17 00:00:00 2001 From: kjuulh Date: Mon, 18 Sep 2023 21:25:45 +0200 Subject: [PATCH] feat: with envelope tests Signed-off-by: kjuulh --- Cargo.lock | 7 +++++++ crates/crunch-envelope/Cargo.toml | 3 +++ crates/test-bin/Cargo.toml | 9 +++++++++ crates/test-bin/src/main.rs | 27 +++++++++++++++++++++++++++ perf.data | Bin 1544 -> 0 bytes 5 files changed, 46 insertions(+) create mode 100644 crates/test-bin/Cargo.toml create mode 100644 crates/test-bin/src/main.rs delete mode 100644 perf.data diff --git a/Cargo.lock b/Cargo.lock index 958ecaf..3a5b15b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -729,6 +729,13 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "test-bin" +version = "0.1.0" +dependencies = [ + "crunch-envelope", +] + [[package]] name = "textwrap" version = "0.16.0" diff --git a/crates/crunch-envelope/Cargo.toml b/crates/crunch-envelope/Cargo.toml index 9d4ee5d..4ba9c6f 100644 --- a/crates/crunch-envelope/Cargo.toml +++ b/crates/crunch-envelope/Cargo.toml @@ -9,6 +9,9 @@ edition = "2021" name = "envelope_benchmark" harness = false +[profile.bench] +debug = true + [features] default = ["json"] json = ["dep:serde", "dep:serde_json", "dep:base64"] diff --git a/crates/test-bin/Cargo.toml b/crates/test-bin/Cargo.toml new file mode 100644 index 0000000..1485ae8 --- /dev/null +++ b/crates/test-bin/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "test-bin" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +crunch-envelope.workspace = true diff --git a/crates/test-bin/src/main.rs b/crates/test-bin/src/main.rs new file mode 100644 index 0000000..d2c1cbd --- /dev/null +++ b/crates/test-bin/src/main.rs @@ -0,0 +1,27 @@ +fn main() { + #[no_mangle] + fn envelope_capnp_benchmark(content: &[u8]) -> () { + let out = crunch_envelope::wrap("some-domain", "some-entity", content); + + let out = crunch_envelope::unwrap(&out).expect("to be able to unwrap capnp message"); + + println!("{:?}", out.1); + } + + #[no_mangle] + fn envelope_json_benchmark(content: &[u8]) -> () { + let out = crunch_envelope::json::wrap("some-domain", "some-entity", content); + + let out = crunch_envelope::json::unwrap(&out).expect("to be able to unwrap capnp message"); + + println!("{:?}", out.1); + } + + let large_content: [u8; 1000000] = [0; 1000000]; + + _ = envelope_capnp_benchmark(&large_content); + + _ = envelope_json_benchmark(&large_content); + + println!("done") +} diff --git a/perf.data b/perf.data deleted file mode 100644 index 54222ad550f2b577c7930a05ae1b0d0d007c49a2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1544 zcmb`GyG{Z@7)D3&f_J>)UC=@r6N0en17O6MXy~j6>Jm-7AhEEsvEUIbvGXx_3KM-6 zl9k>4&caG%q6s-Ob7m&%_y2R2FCG?7@|kPn|GkN+zVN)MxpWU&FOQ!+i(Lz&8jp$N z;)FOUPKhybTAUGQ#W`_aToB{pqPQe3i!0))xF)WP8)8CCiZ1G1K9-13C}!^u?e&#M3WB@(@oS4a-A3{S}pmc=~Qc9^$D#IYK;rN{$du z|B@rb)7Rt(@zjwVA)a?Yju6lLAV-Mj-H;>1^Pb2N;(2G}2=Tl>a)fyLn;aoNp}LSG z#3$v+5#kG;Pnq9+tz!X>y;02g{T(-c4o87E?cm%yE~=H%Q>}bgeYm~3w@X$wo5}5_ t4|2KA&d}&D_gGf@s?h1q#D7<5