Skip to content

Commit

Permalink
neater bench heading
Browse files Browse the repository at this point in the history
  • Loading branch information
liborty committed Sep 11, 2023
1 parent 9c4baf6 commit ec4531d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Times [<img alt="crates.io" src="https://img.shields.io/crates/v/times?logo=rust">](https://crates.io/crates/times) [<img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/liborty/times/HEAD?logo=github">](https://github.com/liborty/times)[![Actions Status](https://github.com/liborty/times/workflows/test/badge.svg)](https://github.com/liborty/times/actions)
# Times [![crates.io](https://img.shields.io/crates/v/times?logo=rust)](https://crates.io/crates/times) [![crates.io](https://img.shields.io/crates/d/times?logo=rust)](https://crates.io/crates/times) [![GitHub last commit](https://img.shields.io/github/last-commit/liborty/times/HEAD?logo=github)](https://github.com/liborty/times) [![Actions Status](https://github.com/liborty/times/actions/workflows/test.yml/badge.svg)](https://github.com/liborty/times/actions)

**Author: Libor Spacek**
## Author: Libor Spacek

Benchmark for Timing and Comparing Algorithms in Rust
Benchmark for Timing and Comparing Algorithms in Rust.
Written in 100% safe Rust.

## Usage

Expand Down
6 changes: 4 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use core::ops::Range;
use devtimer::DevTime;
use indxvec::{printing::*, Indices, Vecops};
use medians::{Medianf64};
use medians::Medianf64;
use ran::{generators::get_seed, *};

fn report(names: &[&str], meds: &[f64], stderrs: &[f64]) {
Expand All @@ -29,7 +29,9 @@ fn heading(data:&str,c1:usize,c2:usize,step:usize,rows:usize,repeats:usize) {
pub fn bench(repeats: usize, names: &[&str], closures: &[fn()]) {
let algno = names.len();
let mut timer = DevTime::new_simple();
heading("none",1,1,0,0,repeats);
println!(
"\n{YL}Input Data: {GR}none {YL}repeats: {GR}{repeats}{UN}"
);
let mut meds = Vec::with_capacity(algno);
let mut stderrs = Vec::with_capacity(algno);
let seed = get_seed(); // store the seed, whatever it is
Expand Down
8 changes: 4 additions & 4 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn benchtests() {
|v:&mut[_]| { v.muthashsort(|t:&f64| *t); },
|v:&mut[_]| { v.mutquicksort(); } ];

set_seeds(7777777777_u64); // intialise random numbers generator
set_seeds(0); // intialise random numbers generator
// Rnum encapsulates the type of the data items
mutbenchu8(Rnum::newu8(),5..10000,2000,10,&NAMES,&CLOSURESU8);
mutbenchu16(Rnum::newu16(),5..10000,2000,10,&NAMES,&CLOSURESU16);
Expand All @@ -48,7 +48,7 @@ fn benchtests() {
fn rantest() {
const D:usize = 10000;
const N:usize = 20;
println!( "{GR}Generating {} sets of vectors of length {} each{UN}",N, D );
println!("\n{GR}Generating {} sets of vectors of length {} each{UN}",N, D );

const NAMES:[&str;4] = [ "ranvvu8","ranvvu16","ranvvu64","ranvvf64" ];

Expand All @@ -58,7 +58,7 @@ fn rantest() {
|| { ranvvu64(D,N).unwrap(); },
|| { ranvvf64(D,N).unwrap(); } ];

set_seeds(7777777777_u64); // intialise random numbers generator
set_seeds(0); // intialise random numbers generator
// Rnum encapsulates the type of the data items
bench(4,&NAMES,&CLOSURES);
bench(8,&NAMES,&CLOSURES);
}

0 comments on commit ec4531d

Please sign in to comment.