Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -359,4 +359,8 @@ zip = { workspace = true }

[[bench]]
name = "dex"
harness = false

[[bench]]
name = "pe"
harness = false
6 changes: 4 additions & 2 deletions lib/benches/dex.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use criterion::{Criterion, black_box, criterion_group, criterion_main};

mod commons;

Expand All @@ -13,7 +13,9 @@ fn bench_dex(c: &mut Criterion) {

group.bench_function("parse", |b| {
b.iter(|| {
let _ = black_box(yara_x::mods::invoke::<yara_x::mods::Dex>(black_box(&data)));
let _ = black_box(yara_x::mods::invoke::<yara_x::mods::Dex>(
black_box(&data),
));
});
});

Expand Down
26 changes: 26 additions & 0 deletions lib/benches/pe.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use criterion::{Criterion, black_box, criterion_group, criterion_main};

mod commons;

use commons::create_binary_from_zipped_ihex;

fn bench_pe(c: &mut Criterion) {
let data = create_binary_from_zipped_ihex(
"src/modules/pe/tests/testdata/c704cca0fe4c9bdee18a302952540073b860e3b4d42e081f86d27bdb1cf6ede4.in.zip",
);

let mut group = c.benchmark_group("pe");

group.bench_function("parse", |b| {
b.iter(|| {
let _ = black_box(yara_x::mods::invoke::<yara_x::mods::PE>(
black_box(&data),
));
});
});

group.finish();
}

criterion_group!(benches, bench_pe);
criterion_main!(benches);
2 changes: 1 addition & 1 deletion lib/src/modules/dex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn main(data: &[u8], _meta: Option<&[u8]>) -> Result<Dex, ModuleError> {
SIGNATURE_CACHE.with(|cache| *cache.borrow_mut() = None);

match parser::Dex::parse(data) {
Ok(dex) => Ok(dex.into()),
Ok(dex) => Ok(dex),
Err(_) => {
let mut dex = Dex::new();
dex.set_is_dex(false);
Expand Down
Loading
Loading