Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. use std::time::{Instant, Duration};
  2.  
  3. pub fn main() {
  4. let mut counter = 0;
  5. let mut times = Vec::with_capacity(1000);
  6. let start = Instant::now();
  7.  
  8. loop {
  9. counter += 1;
  10.  
  11. if counter >= 1000 {
  12. break;
  13. }
  14.  
  15. times.push(Instant::now());
  16. }
  17.  
  18. let mut times: Vec<Duration> = times.iter().map(|t| *t - start).collect();
  19. times.sort();
  20.  
  21. println!("{}", times[times.len() / 2].as_nanos());
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement