Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::time::{Instant, Duration};
- use std::sync::atomic::spin_loop_hint;
- pub fn main() {
- let mut last = Instant::now();
- let mut counter = 0;
- loop {
- counter += 1;
- let mut now = Instant::now();
- if counter % 10000 == 0 {
- let now = Instant::now();
- let diff = now - last;
- println!("{}", diff.as_nanos());
- }
- while (now - last) < Duration::from_nanos(186) {
- spin_loop_hint();
- now = Instant::now();
- }
- last = now;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement