forked from lambdaclass/cairo-vm
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathiai_benchmark.rs
72 lines (63 loc) · 1.96 KB
/
iai_benchmark.rs
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use core::hint::black_box;
use iai_callgrind::main;
use cairo_vm::{
types::{layout_name::LayoutName, program::Program},
vm::runners::cairo_runner::CairoRunner,
};
use mimalloc::MiMalloc;
#[global_allocator]
static ALLOC: MiMalloc = MiMalloc;
#[inline(never)]
fn parse_program() {
//Picked the biggest one at the time of writing
let program = include_bytes!("../cairo_programs/benchmarks/keccak_integration_benchmark.json");
let program =
Program::from_bytes(black_box(program.as_slice()), black_box(Some("main"))).unwrap();
core::mem::drop(black_box(program));
}
#[export_name = "helper::parse_program"]
#[inline(never)]
fn parse_program_helper() -> Program {
//Picked the biggest one at the time of writing
let program = include_bytes!("../cairo_programs/benchmarks/keccak_integration_benchmark.json");
Program::from_bytes(program.as_slice(), Some("main")).unwrap()
}
#[inline(never)]
fn build_runner() {
let program = parse_program_helper();
let runner = CairoRunner::new(
black_box(&program),
LayoutName::starknet_with_keccak,
None,
false,
false,
false,
)
.unwrap();
core::mem::drop(black_box(runner));
}
#[export_name = "helper::build_runner"]
#[inline(never)]
fn build_runner_helper() -> CairoRunner {
//Picked the biggest one at the time of writing
let program = include_bytes!("../cairo_programs/benchmarks/keccak_integration_benchmark.json");
let program = Program::from_bytes(program.as_slice(), Some("main")).unwrap();
CairoRunner::new(
&program,
LayoutName::starknet_with_keccak,
None,
false,
false,
false,
)
.unwrap()
}
#[inline(never)]
fn load_program_data() {
let mut runner = build_runner_helper();
_ = black_box(runner.initialize(false).unwrap());
}
main!(
callgrind_args = "toggle-collect=helper::*,core::mem::drop";
functions = parse_program, build_runner, load_program_data
);