MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / function_benchmark

Function function_benchmark

plugins/warp/benches/function.rs:8–42  ·  view source on GitHub ↗
(c: &mut Criterion)

Source from the content-addressed store, hash-verified

6use warp_ninja::cache::FunctionCache;
7
8pub fn function_benchmark(c: &mut Criterion) {
9 let session = Session::new().expect("Failed to initialize session");
10 let bv = session.load(env!("TEST_BIN_LIBRARY_OBJ")).unwrap();
11 let functions = bv.functions();
12 assert_eq!(functions.len(), 6);
13 let mut function_iter = functions.into_iter();
14 let first_function = function_iter.next().unwrap();
15
16 c.bench_function("signature first function", |b| {
17 b.iter(|| {
18 let _ = build_function(&first_function, &first_function.low_level_il().unwrap());
19 })
20 });
21
22 c.bench_function("signature all functions", |b| {
23 b.iter(|| {
24 for func in &functions {
25 let _ = build_function(&func, &func.low_level_il().unwrap());
26 }
27 })
28 });
29
30 let cache = FunctionCache::default();
31 c.bench_function("signature all functions rayon", |b| {
32 b.iter(|| {
33 functions
34 .par_iter()
35 .map_with(cache.clone(), |par_cache, func| {
36 let llil = func.low_level_il().ok()?;
37 Some(par_cache.function(func.as_ref(), llil.as_ref()))
38 })
39 .collect::<Vec<_>>()
40 })
41 });
42}
43
44criterion_group!(benches, function_benchmark);
45criterion_main!(benches);

Callers

nothing calls this directly

Calls 11

build_functionFunction · 0.85
par_iterMethod · 0.80
loadMethod · 0.45
functionsMethod · 0.45
into_iterMethod · 0.45
nextMethod · 0.45
iterMethod · 0.45
low_level_ilMethod · 0.45
cloneMethod · 0.45
functionMethod · 0.45
as_refMethod · 0.45

Tested by

no test coverage detected