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 54222ad..0000000 Binary files a/perf.data and /dev/null differ