From 9e575a36215117625a57d5e123380135354975c8 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Wed, 20 Apr 2022 12:01:36 +0200 Subject: [PATCH] Try harder to use user cpu time --- src/bin/test.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/bin/test.rs b/src/bin/test.rs index 2bfe7cfc..10bf910c 100644 --- a/src/bin/test.rs +++ b/src/bin/test.rs @@ -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}");