use pipedconsole::*;
use std::time::Instant;
use std::io::Write;
const TEST_RANGE: u32 = 100_000;
const TEST_RANGE_SMALL: u32 = 500;
#[test]
fn template() {
let _console = Console::new("UNNAMED").unwrap();
let start = Instant::now();
for _ in 0..TEST_RANGE {
};
let duration = Instant::now() - start;
println!("TEMPLATE()\nTook {:?}\nThat is {:?} per call.", duration, duration / TEST_RANGE);
read!();
}
#[test]
fn perf_flush() {
let mut console = Console::new("PERF_FLUSH").unwrap();
console.flush().unwrap();
let start = Instant::now();
for _ in 0..TEST_RANGE {
console.flush().unwrap();
};
let duration = Instant::now() - start;
println!("flush()\nTook {:?}\nThat is {:?} per call.", duration, duration / TEST_RANGE);
read!();
}
#[test]
fn perf_new() {
let start = Instant::now();
for _ in 0..TEST_RANGE_SMALL {
Console::new("Normal").unwrap();
};
let duration = Instant::now() - start;
println!("new()\nTook {:?}\nThat is {:?} per call.", duration, duration / TEST_RANGE_SMALL);
read!();
}
#[macro_export]
macro_rules! read {
() => {
{ std::io::stdin().read_line(&mut String::new()).unwrap_or_default(); }
};
}