Add HighResolutionClock replacing the standard clock

master
Trivernis 4 years ago
parent 153f645605
commit 744b316055

@ -1,6 +1,6 @@
[package]
name = "benchlib-rs"
version = "0.3.4"
version = "0.4.0"
authors = ["Trivernis <trivernis@gmail.com>"]
edition = "2018"
license-file = "LICENSE"
@ -16,3 +16,4 @@ crate-type = ["lib"]
[dependencies]
rayon = "1.3.0"
termion = "1.5.5"
howlong = "0.1.3"

@ -1,12 +1,16 @@
use howlong::*;
use std::fmt::{self, Display};
use std::fs::File;
use std::io;
use std::io::{BufWriter, Write};
use std::time::{Duration, Instant};
use std::time::Instant;
use rayon::prelude::*;
use termion::{color, style};
#[derive(Debug, Clone)]
pub struct BenchDuration {}
#[derive(Debug, Clone)]
pub struct BenchVec {
pub inner: Vec<Duration>,
@ -151,8 +155,8 @@ impl Bencher {
fn calculate_bench_duration() -> Duration {
let mut durations = BenchVec::new();
for _ in 0..1000 {
let start = Instant::now();
durations.push(start.elapsed());
let start = HighResolutionClock::now();
durations.push(HighResolutionClock::now() - start);
}
durations.average()

Loading…
Cancel
Save