Skip to content

Commit 6ed86d9

Browse files
committed
benches/inger.rs: Make resume benchmark reuse functions so it no longer 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.
1 parent 081034c commit 6ed86d9

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

benches/inger.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,22 @@ fn launch(lo: &mut Bencher) {
6363
fn resume(lo: &mut Bencher) {
6464
use inger::launch;
6565
use inger::resume;
66+
use std::sync::atomic::AtomicBool;
6667

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

7376
let mut into = 0;
7477
let mut outof = 0;
7578
let mut index = 0;
7679
lo.iter(|| {
77-
assert!(index < lingers.len(), "LIBSETS tunable set too low!");
78-
7980
let before = nsnow();
80-
resume(&mut lingers[index], u64::max_value()).unwrap();
81+
resume(&mut lingers[index % nlingers], u64::max_value()).unwrap();
8182

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

97-
for linger in &mut lingers[index..] {
98+
run.store(false, Ordering::Relaxed);
99+
for linger in &mut lingers {
98100
resume(linger, u64::max_value()).unwrap();
99101
}
100102
}

0 commit comments

Comments
 (0)