Skip to content

Commit

Permalink
benches/inger.rs: Make resume benchmark reuse functions so it no long…
Browse files Browse the repository at this point in the history
…er runs out of libsets

The launch and resume benchmarks now run to successful completion, both with and without global
variable interposition, provided libgotcha and the dynamic linker support 511 libsets.
  • Loading branch information
solb committed Jan 1, 2020
1 parent 081034c commit 6ed86d9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions benches/inger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,22 @@ fn launch(lo: &mut Bencher) {
fn resume(lo: &mut Bencher) {
use inger::launch;
use inger::resume;
use std::sync::atomic::AtomicBool;

let run = AtomicBool::from(true);
let during = AtomicU64::default();
let mut lingers: Vec<_> = (0..LIBSETS).map(|_| launch(|| {
let mut lingers: Vec<_> = (0..LIBSETS).map(|_| launch(|| while run.load(Ordering::Relaxed) {
pause();
during.store(nsnow(), Ordering::Relaxed);
}, u64::max_value()).unwrap()).collect();
let nlingers = lingers.len();

let mut into = 0;
let mut outof = 0;
let mut index = 0;
lo.iter(|| {
assert!(index < lingers.len(), "LIBSETS tunable set too low!");

let before = nsnow();
resume(&mut lingers[index], u64::max_value()).unwrap();
resume(&mut lingers[index % nlingers], u64::max_value()).unwrap();

let after = nsnow();
let during = during.load(Ordering::Relaxed);
Expand All @@ -94,7 +95,8 @@ fn resume(lo: &mut Bencher) {
writeln!(file, "(ran for {} iterations)", index).unwrap();
}

for linger in &mut lingers[index..] {
run.store(false, Ordering::Relaxed);
for linger in &mut lingers {
resume(linger, u64::max_value()).unwrap();
}
}
Expand Down

0 comments on commit 6ed86d9

Please sign in to comment.