Skip to content

Commit

Permalink
improve timer
Browse files Browse the repository at this point in the history
  • Loading branch information
JieningYu committed Dec 27, 2022
1 parent 81dcf19 commit 65b1066
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ fn main() {
thread::spawn(move || {
let mut i: u64 = 0;
loop {
thread::sleep(Duration::from_millis(1));
if rxb.try_recv().is_ok() {
tx.send(i).unwrap();
break;
}
thread::sleep(Duration::from_micros(1));
i += 1;
if rxb.try_recv().is_ok() {
tx.send(i).unwrap();
Expand All @@ -81,7 +85,7 @@ fn main() {
for (i, _item) in solutions.iter().enumerate() {
println!("{}", solutions[i].to_string());
}
println!("Found {} solutions in {} ms", solutions.len(), dur);
println!("Found {} solutions in {} ms", solutions.len(), (dur as f64) * 0.001);
}
}
}
Expand Down

0 comments on commit 65b1066

Please sign in to comment.