Skip to content

Commit

Permalink
Benches: call spin_loop() in two-threads/small
Browse files Browse the repository at this point in the history
  • Loading branch information
mgeier committed Dec 16, 2023
1 parent 2686a28 commit 8440c20
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions benches/two_threads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,19 @@ pub fn add_function<P, C, Create, Push, Pop, M>(
std::thread::spawn(move || {
barrier.wait();
for _ in 0..iters {
while !push(&mut p, black_box(42)) {}
while !push(&mut p, black_box(42)) {
std::hint::spin_loop();
}
}
barrier.wait();
})
};
barrier.wait();
let start = std::time::Instant::now();
for _ in 0..iters {
while pop(&mut c).is_none() {}
while pop(&mut c).is_none() {
std::hint::spin_loop();
}
}
barrier.wait();
let duration = start.elapsed();
Expand Down

0 comments on commit 8440c20

Please sign in to comment.