Skip to content

Commit

Permalink
Try harder to use user cpu time
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-Shadle committed Apr 20, 2022
1 parent bcaa415 commit 9e575a3
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/bin/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,14 @@ mod mac {
let thread = mach2::mach_init::mach_thread_self();

// Busy loop for 1 second just so we accrue user thread time
std::thread::spawn(move || {
let start = std::time::Instant::now();
while (std::time::Instant::now() - start).as_secs() < 1 {
eprint!(".");
}
})
.join()
.unwrap();
let start = std::time::Instant::now();
let mut counter = 0;
while (std::time::Instant::now() - start).as_secs() < 2 {
counter += 1;
std::thread::sleep(std::time::Duration::from_millis(10));
}

eprintln!("counted to {}", counter);

println!("{task} {thread}");

Expand Down

0 comments on commit 9e575a3

Please sign in to comment.