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;
- use std::convert::TryInto;
- use slog::*;
- pub fn main() {
- let decorator = slog_term::TermDecorator::new().build();
- let drain = slog_term::CompactFormat::new(decorator).build().fuse();
- let drain = slog_async::Async::new(drain).build().fuse();
- let log = slog::Logger::root(drain, o!());
- let mut counter = 0;
- let mut times = Vec::with_capacity(1000);
- let start = Instant::now();
- loop {
- counter += 1;
- if counter >= 1000 {
- break;
- }
- times.push(Instant::now());
- }
- let mut times: Vec<Duration> = times.iter().map(|t| *t - start).collect();
- times.sort();
- info!(log, "{}", times[times.len() / 2].as_nanos());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement