Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Benchmark #655

Merged
merged 3 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 16 additions & 0 deletions rust/bench/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "bench"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cardano-serialization-lib = { path = ".." }

[dev-dependencies]
criterion = "0.5.1"

[[bench]]
name = "benches_main"
harness = false
7 changes: 7 additions & 0 deletions rust/bench/benches/benches_main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use criterion::criterion_main;

mod block_bench;

criterion_main! {
block_bench::benches
}
15 changes: 15 additions & 0 deletions rust/bench/benches/block_bench.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use cardano_serialization_lib::Block;
use criterion::{black_box, criterion_group, criterion_main, Criterion};

fn bench_decode_block(c: &mut Criterion) {
let raw_data = include_bytes!("data/block_with_certs.bin").to_vec();
c.bench_function("decode block", |b| {
b.iter(|| {
let data_copy = raw_data.clone();
let block = Block::from_bytes(data_copy);
assert!(block.is_ok());
})
});
}

criterion_group!(benches, bench_decode_block);
Binary file added rust/bench/benches/data/block_with_certs.bin
Binary file not shown.
Loading