#performances #testing

macro performances-testing

A performances testing library

13 releases

0.1.5 Dec 9, 2023
0.1.4 Dec 8, 2023
0.1.0 May 22, 2023
0.0.8 Apr 19, 2023
0.0.6 Mar 13, 2023

#1536 in Development tools

Download history 1/week @ 2023-11-02 2/week @ 2023-11-09 1/week @ 2023-11-16 9/week @ 2023-11-23 29/week @ 2023-11-30 113/week @ 2023-12-07 18/week @ 2023-12-14 26/week @ 2023-12-21 13/week @ 2023-12-28 8/week @ 2024-01-04 4/week @ 2024-01-11 13/week @ 2024-01-25 13/week @ 2024-02-01 14/week @ 2024-02-08 153/week @ 2024-02-15

193 downloads per month

GPL-2.0-or-later

120KB
165 lines

Installation

cargo add performances-testing

build status tests status clippy status documentation build check status

performances-testing output

Usage

use performances::performances::Performances;
use performances::{f32, f64, micros, millis, nanos, secs};
use std::collections::HashMap;
use std::process::{exit, ExitCode};
use std::thread::sleep;
use std::time::Duration;

fn live() {
    let t = Duration::from_secs_f32(7.0f32);
    sleep(t);
}

fn forgive() {
    let t = Duration::from_secs_f32(8.0f32);
    sleep(t);
}

fn life() {
    let t = Duration::from_secs_f64(7.0f64);
    sleep(t);
}

fn forever() {
    let t = Duration::from_secs_f64(8.0f64);
    sleep(t);
}

fn like() {
    let t = Duration::from_micros(7_000);
    sleep(t);
}

fn wife() {
    let t = Duration::from_nanos(7_000_000);
    sleep(t);
}

fn me() {
    let t = Duration::from_nanos(9_000_000);
    sleep(t);
}

fn knife() {
    let t = Duration::from_millis(7_000);
    sleep(t);
}

fn you() {
    let t = Duration::from_millis(8_000);
    sleep(t);
}

fn chipper() {
    let t = Duration::from_secs(1);
    sleep(t);
}

fn www() {
    let t = Duration::from_secs(2);
    sleep(t);
}

fn main() -> ExitCode {
    let mut callback_f32: HashMap<fn(), f32> = HashMap::new();
    let mut callback_f64: HashMap<fn(), f64> = HashMap::new();
    let mut callback_nanos: HashMap<fn(), u128> = HashMap::new();
    let mut callback_millis: HashMap<fn(), u128> = HashMap::new();
    let mut callback_micros: HashMap<fn(), u128> = HashMap::new();
    let mut callback_secs: HashMap<fn(), u64> = HashMap::new();

    callback_f32.insert(live, 8.0f32);
    callback_f32.insert(forgive, 9.0f32);
    callback_f64.insert(life, 8.0f64);
    callback_f64.insert(forever, 9.0f64);
    callback_nanos.insert(wife, 8_000_0000);
    callback_nanos.insert(me, 10_000_0000);
    callback_millis.insert(knife, 8_000);
    callback_millis.insert(you, 9_000);
    callback_micros.insert(like, 8_000);
    callback_micros.insert(like, 8_000);
    callback_secs.insert(chipper, 2);
    callback_secs.insert(www, 3);

    f32!(callback_f32);
    f64!(callback_f64);
    nanos!(callback_nanos);
    millis!(callback_millis);
    micros!(callback_micros);
    secs!(callback_secs);

    exit(0);
}

Run test

cargo run     

Dependencies

~1.5MB
~25K SLoC