feat: with protobuf

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2023-09-19 08:31:13 +02:00
parent d4d5374392
commit 41f36c09be
8 changed files with 387 additions and 31 deletions

View File

@@ -13,6 +13,12 @@ fn envelope_json_benchmark(content: &[u8]) -> () {
let _ = crunch_envelope::json::unwrap(&out).expect("to be able to unwrap capnp message");
}
fn envelope_proto_benchmark(content: &[u8]) -> () {
let out = crunch_envelope::proto::wrap("some-domain", "some-entity", content);
let _ = crunch_envelope::proto::unwrap(&out).expect("to be able to unwrap capnp message");
}
fn criterion_benchmark(c: &mut Criterion) {
let large_content: [u8; 10000] = [0; 10000];
@@ -22,6 +28,9 @@ fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("envelope::json", |b| {
b.iter(|| envelope_json_benchmark(&large_content))
});
c.bench_function("envelope::proto", |b| {
b.iter(|| envelope_proto_benchmark(&large_content))
});
}
criterion_group!(benches, criterion_benchmark);