(c: &mut Criterion)
| 6 | use warp_ninja::cache::FunctionCache; |
| 7 | |
| 8 | pub 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 | |
| 44 | criterion_group!(benches, function_benchmark); |
| 45 | criterion_main!(benches); |
nothing calls this directly
no test coverage detected