blob: 7d7f40b3c39276430a29e3e79afe0fc794b01c9e (
plain)
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
|
use binaryninja::binary_view::BinaryViewExt;
use binaryninja::headless::Session;
use criterion::{criterion_group, criterion_main, Criterion};
use std::path::PathBuf;
use warp_ninja::convert::from_bn_type;
pub fn type_conversion_benchmark(c: &mut Criterion) {
let session = Session::new().expect("Failed to initialize session");
let out_dir = env!("OUT_DIR").parse::<PathBuf>().unwrap();
for entry in std::fs::read_dir(out_dir).expect("Failed to read OUT_DIR") {
let entry = entry.expect("Failed to read directory entry");
let path = entry.path();
if path.is_file() {
if let Some(bv) = session.load(path.to_str().unwrap()) {
let functions = bv.functions();
c.bench_function("type conversion all functions", |b| {
b.iter(|| {
for func in &functions {
from_bn_type(&bv, &func.function_type(), u8::MAX);
}
})
});
let types = bv.types();
c.bench_function("type conversion all types", |b| {
b.iter(|| {
for ty in &types {
from_bn_type(&bv, &ty.ty, u8::MAX);
}
})
});
}
}
}
}
criterion_group!(benches, type_conversion_benchmark);
criterion_main!(benches);
|