-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #655 from Emurgo/evgenii/perfomace-test
Benchmark
- Loading branch information
Showing
4 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.