-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add simple benchmarks with static obj files
- Loading branch information
1 parent
1c702b5
commit 72fe990
Showing
5 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
use criterion::{black_box, criterion_group, criterion_main, Criterion}; | ||
use lc3sim_project::{ | ||
executors::{core::CoreLC3, populate_from_bin, LC3}, | ||
harnesses::{simple::FailIO, sync::step_continue}, | ||
}; | ||
|
||
macro_rules! setup_lc3 { | ||
( $lc3:ident, $path:literal ) => { | ||
|| { | ||
let mut lc3 = $lc3.clone(); | ||
populate_from_bin(&mut lc3, include_bytes!("../penn_sim/lc3os.obj").as_slice()); | ||
populate_from_bin(&mut lc3, include_bytes!($path).as_slice()); | ||
lc3 | ||
} | ||
}; | ||
} | ||
|
||
pub fn create_new(c: &mut Criterion) { | ||
let mut c = c.benchmark_group("create_new"); | ||
|
||
macro_rules! bench_new { | ||
( $lc3:expr, $name: literal ) => { | ||
c.bench_function($name, |b| { | ||
b.iter($lc3); | ||
}); | ||
}; | ||
} | ||
|
||
bench_new!(CoreLC3::new, "core"); | ||
#[cfg(feature = "consolidated")] | ||
bench_new!( | ||
lc3sim_project::executors::consolidated::ConsolidatedLC3::boxed, | ||
"consolidated" | ||
); | ||
} | ||
|
||
pub fn load_os(c: &mut Criterion) { | ||
let mut c = c.benchmark_group("load_os"); | ||
|
||
fn exec_setup<E: LC3>(mut lc3: E) -> E { | ||
populate_from_bin(&mut lc3, include_bytes!("../penn_sim/lc3os.obj").as_slice()); | ||
black_box(lc3) | ||
} | ||
|
||
macro_rules! bench_load { | ||
( $lc3:expr, $name: literal ) => { | ||
c.bench_function($name, |b| { | ||
b.iter_batched($lc3, exec_setup, criterion::BatchSize::SmallInput); | ||
}); | ||
}; | ||
} | ||
|
||
bench_load!(CoreLC3::new, "core"); | ||
#[cfg(feature = "consolidated")] | ||
bench_load!( | ||
lc3sim_project::executors::consolidated::ConsolidatedLC3::boxed, | ||
"consolidated" | ||
); | ||
} | ||
|
||
pub fn tiny_loop(c: &mut Criterion) { | ||
let mut c = c.benchmark_group("tiny_loop"); | ||
|
||
fn exec_loop<E: LC3>(mut lc3: E) { | ||
step_continue(&mut FailIO, &mut lc3).unwrap(); | ||
} | ||
|
||
macro_rules! bench_loop { | ||
( $lc3:expr, $name: literal ) => { | ||
let lc3 = $lc3; | ||
c.bench_function($name, |b| { | ||
b.iter_batched( | ||
setup_lc3!(lc3, "../test_data/custom/loop.obj"), | ||
exec_loop, | ||
criterion::BatchSize::SmallInput, | ||
); | ||
}); | ||
}; | ||
} | ||
|
||
bench_loop!(CoreLC3::new(), "core"); | ||
#[cfg(feature = "consolidated")] | ||
bench_loop!( | ||
lc3sim_project::executors::consolidated::ConsolidatedLC3::boxed(), | ||
"consolidated" | ||
); | ||
} | ||
|
||
criterion_group!(speed_compare, create_new, load_os, tiny_loop); | ||
criterion_main!(speed_compare); |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.ORIG x3000 | ||
AND R0, R0, #0 | ||
LOOP ADD R0, R0, #1 | ||
BRnp LOOP | ||
HALT |
Binary file not shown.