summaryrefslogtreecommitdiff
path: root/plugins/warp/benches/function.rs
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2024-10-23 20:47:31 -0400
committerMason Reed <mason@vector35.com>2024-10-24 17:03:11 -0400
commite151425087b6c0ee8c4d099bfc2d6d1268201db0 (patch)
tree25160cf81aa6d650cf1497a078acc50f0062757c /plugins/warp/benches/function.rs
parent0f53c21d6a7abbfd48fd59ec7c15586f02777b7e (diff)
Add WARP integration
https://github.com/Vector35/warp/
Diffstat (limited to 'plugins/warp/benches/function.rs')
-rw-r--r--plugins/warp/benches/function.rs42
1 files changed, 42 insertions, 0 deletions
diff --git a/plugins/warp/benches/function.rs b/plugins/warp/benches/function.rs
new file mode 100644
index 00000000..c6f6d70d
--- /dev/null
+++ b/plugins/warp/benches/function.rs
@@ -0,0 +1,42 @@
+use binaryninja::binaryview::BinaryViewExt;
+use binaryninja::headless::Session;
+use criterion::{criterion_group, criterion_main, Criterion};
+use rayon::prelude::*;
+use warp_ninja::build_function;
+use warp_ninja::cache::FunctionCache;
+
+pub fn function_benchmark(c: &mut Criterion) {
+ let session = Session::new();
+ 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();
+
+ c.bench_function("signature first function", |b| {
+ b.iter(|| {
+ let _ = build_function(&first_function, &first_function.low_level_il().unwrap());
+ })
+ });
+
+ c.bench_function("signature all functions", |b| {
+ b.iter(|| {
+ for func in &functions {
+ let _ = build_function(&func, &func.low_level_il().unwrap());
+ }
+ })
+ });
+
+ let cache = FunctionCache::default();
+ c.bench_function("signature all functions rayon", |b| {
+ b.iter(|| {
+ functions
+ .par_iter()
+ .map_with(cache.clone(), |par_cache, func| par_cache.function(&func))
+ .collect::<Vec<_>>()
+ })
+ });
+}
+
+criterion_group!(benches, function_benchmark);
+criterion_main!(benches);