Skip to content

Commit

Permalink
Added a bench for loaded modules
Browse files Browse the repository at this point in the history
  • Loading branch information
ohadravid committed Jun 4, 2019
1 parent 15851de commit 40ac0ef
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/benches/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ pub struct Process {
pub Caption: String,
}

#[derive(Serialize, Deserialize, Debug)]
#[serde(rename = "CIM_ProcessExecutable")]
pub struct ProcessExecutable {
pub BaseAddress: String,
pub Antecedent: String,
pub Dependent: String,
}

fn get_accounts(con: &WMIConnection) {
let accounts: Vec<Account> = con.query().unwrap();
}
Expand Down Expand Up @@ -82,6 +90,10 @@ pub fn get_users_with_groups(con: &WMIConnection) {
.unwrap();
}

pub fn get_modules(con: &WMIConnection) {
let execs: Vec<ProcessExecutable> = con.query().unwrap();
}

fn criterion_benchmark(c: &mut Criterion) {
// baseline: 41ms
c.bench_function("get_accounts", |b| {
Expand Down Expand Up @@ -119,6 +131,12 @@ fn criterion_benchmark(c: &mut Criterion) {
let wmi_con = WMIConnection::new(COMLibrary::new().unwrap().into()).unwrap();
b.iter(|| get_users_with_groups(&wmi_con))
});

// baseline: 625ms.
c.bench_function("get_modules", |b| {
let wmi_con = WMIConnection::new(COMLibrary::new().unwrap().into()).unwrap();
b.iter(|| get_modules(&wmi_con))
});
}

criterion_group!(benches, criterion_benchmark);
Expand Down

0 comments on commit 40ac0ef

Please sign in to comment.