summaryrefslogtreecommitdiff
path: root/plugins/warp/benches/convert.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/convert.rs
parent0f53c21d6a7abbfd48fd59ec7c15586f02777b7e (diff)
Add WARP integration
https://github.com/Vector35/warp/
Diffstat (limited to 'plugins/warp/benches/convert.rs')
-rw-r--r--plugins/warp/benches/convert.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/plugins/warp/benches/convert.rs b/plugins/warp/benches/convert.rs
new file mode 100644
index 00000000..e916d5df
--- /dev/null
+++ b/plugins/warp/benches/convert.rs
@@ -0,0 +1,39 @@
+use binaryninja::binaryview::BinaryViewExt;
+use binaryninja::headless::Session;
+use binaryninja::types::Conf;
+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();
+ 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.type_object().clone(), u8::MAX);
+ }
+ })
+ });
+ }
+ }
+ }
+}
+
+criterion_group!(benches, type_conversion_benchmark);
+criterion_main!(benches);