|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
-
- extern crate logging;
-
- use std::time::{Instant, Duration};
- use std::thread;
-
- use logging::hist::{Entry, HistLog, nanos};
-
- const N_SECS: u64 = 60 * 60;
-
- fn main() {
- let start = Instant::now();
- let mut a = HistLog::new("test", "a", Duration::from_millis(1000));
- let mut b = a.clone_with_tag("b");
- let mut c = b.clone_with_tag("c");
-
- thread::spawn(move || {
-
- let mut prev = Instant::now();
- let mut loop_time = Instant::now();
- let mut i = 0;
-
- loop {
- prev = loop_time;
- loop_time = Instant::now();
- a.record(nanos(loop_time - prev));
- a.check_send(loop_time);
-
-
- if loop_time - start > Duration::from_secs(N_SECS) { break }
-
- i += 1;
- //if i % 100 == 0 { thread::sleep(Duration::new(0, 0)); }
- thread::sleep(Duration::new(0, 0));
- }
- });
-
- thread::spawn(move || {
- let mut prev = Instant::now();
- let mut loop_time = Instant::now();
- let mut i = 0;
-
- loop {
- prev = loop_time;
- loop_time = Instant::now();
- b.record(nanos(loop_time - prev));
- b.check_send(loop_time);
-
- if loop_time - start > Duration::from_secs(N_SECS) { break }
-
- i += 1;
- //if i % 1_000 == 0 { thread::sleep(Duration::new(0, 0)); }
- //if i % 100 == 0 { thread::sleep(Duration::new(0, 0)); }
- thread::sleep(Duration::new(0, 0));
- }
- });
-
- let mut prev = Instant::now();
- let mut loop_time = Instant::now();
- let mut i = 0;
-
- loop {
- prev = loop_time;
- loop_time = Instant::now();
- c.record(nanos(loop_time - prev));
- c.check_send(loop_time);
-
- if loop_time - start > Duration::from_secs(N_SECS) { break }
-
- i += 1;
- //if i % 100_000 == 0 { thread::sleep(Duration::from_millis(10)); }
- //if i % 100 == 0 { thread::sleep(Duration::new(0, 0)); }
- thread::sleep(Duration::new(0, 0));
- }
- }
-
|