-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbuild_empty_cell.rs
More file actions
43 lines (36 loc) · 1.38 KB
/
build_empty_cell.rs
File metadata and controls
43 lines (36 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
mod benchmark_utils;
use criterion::{Criterion, criterion_group, criterion_main};
use ton_lib_core_008::cell::TonCell as TonCellTonLibCore008;
use tonlib_core::cell::CellBuilder;
use std::hint::black_box;
use ton_core::cell::TonCell as TonCellCurrent;
const ITERATIONS_COUNT: usize = 100;
// cargo bench --bench build_empty_cell
fn benchmark_functions(c: &mut Criterion) {
run_bench!(c, build_cell_with_ref_tonlib_core_old);
run_bench!(c, build_cell_with_ref_ton_lib_008);
run_bench!(c, build_cell_with_ref_ton_rs_current);
}
fn build_cell_with_ref_tonlib_core_old() {
for _ in 0..ITERATIONS_COUNT {
let mut builder = CellBuilder::new();
builder.store_child(CellBuilder::new().build().unwrap()).unwrap();
black_box(builder.build().unwrap());
}
}
fn build_cell_with_ref_ton_lib_008() {
for _ in 0..ITERATIONS_COUNT {
let mut builder = TonCellTonLibCore008::builder();
builder.write_ref(TonCellTonLibCore008::builder().build().unwrap().into_ref()).unwrap();
black_box(builder.build().unwrap());
}
}
fn build_cell_with_ref_ton_rs_current() {
for _ in 0..ITERATIONS_COUNT {
let mut builder = TonCellCurrent::builder();
builder.write_ref(TonCellCurrent::builder().build().unwrap()).unwrap();
black_box(builder.build().unwrap());
}
}
criterion_group!(benches, benchmark_functions);
criterion_main!(benches);