summaryrefslogtreecommitdiff
path: root/plugins/warp/benches/guid.rs
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/warp/benches/guid.rs')
-rw-r--r--plugins/warp/benches/guid.rs31
1 files changed, 20 insertions, 11 deletions
diff --git a/plugins/warp/benches/guid.rs b/plugins/warp/benches/guid.rs
index 046886b5..eddf2f06 100644
--- a/plugins/warp/benches/guid.rs
+++ b/plugins/warp/benches/guid.rs
@@ -1,22 +1,31 @@
use binaryninja::binary_view::BinaryViewExt;
use binaryninja::headless::Session;
use criterion::{criterion_group, criterion_main, Criterion};
+use std::path::PathBuf;
use warp_ninja::function_guid;
+// These are the target files present in OUT_DIR
+// Add the files to fixtures/bin
+static TARGET_FILES: [&str; 1] = ["atox.obj"];
+
pub fn guid_benchmark(c: &mut Criterion) {
let session = Session::new().expect("Failed to initialize session");
- let bv = session.load(env!("TEST_BIN_LIBRARY_OBJ")).unwrap();
- let functions = bv.functions();
- assert_eq!(functions.len(), 6);
- let mut function_iter = functions.into_iter();
- let first_function = function_iter.next().unwrap();
+ let out_dir = env!("OUT_DIR").parse::<PathBuf>().unwrap();
+ for file_name in TARGET_FILES {
+ let path = out_dir.join(file_name);
+ let view = session.load(&path).expect("Failed to load view");
- c.bench_function("function guid", |b| {
- b.iter(|| {
- let llil = first_function.low_level_il().unwrap();
- function_guid(&first_function, &llil);
- })
- });
+ let functions: Vec<_> = view.functions().iter().map(|f| f.to_owned()).collect();
+ // Bench all functions sequentially
+ c.bench_function("guid all functions", |b| {
+ b.iter(|| {
+ for func in &functions {
+ let llil = func.lifted_il().unwrap();
+ function_guid(&func, &llil);
+ }
+ })
+ });
+ }
}
criterion_group!(benches, guid_benchmark);