Skip to content
This repository has been archived by the owner on Mar 4, 2023. It is now read-only.

Commit

Permalink
Fix benchmarks
Browse files Browse the repository at this point in the history
Signed-off-by: JP-Ellis <josh@jpellis.me>
  • Loading branch information
JP-Ellis committed Jun 17, 2018
1 parent 64798d9 commit ad265c5
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/statistic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ mod bench {
use csv;
use test::{black_box, Bencher};

type Row6 = (f64, f64, f64, f64, f64, f64);
type Row7 = (f64, f64, f64, f64, f64, f64, f64);

const STEP_SIZE: usize = 10;
Expand Down Expand Up @@ -386,14 +387,14 @@ mod bench {
#[bench]
fn fermi_dirac_massless(b: &mut Bencher) {
let fd = Statistic::FermiDirac;
let rdr = csv::Reader::from_path("test/data/number_density_massive.csv").unwrap();
let data: Vec<Row7> = rdr.into_deserialize()
let rdr = csv::Reader::from_path("test/data/number_density_massless.csv").unwrap();
let data: Vec<Row6> = rdr.into_deserialize()
.step_by(STEP_SIZE)
.map(|r| r.unwrap())
.collect();

b.iter(|| {
for &(_, mu, beta, _, _, _, _) in &data {
for &(mu, beta, _, _, _, _) in &data {
let n = fd.massless_number_density(mu, beta);
black_box(n);
}
Expand All @@ -403,14 +404,14 @@ mod bench {
#[bench]
fn bose_einstein_massless(b: &mut Bencher) {
let be = Statistic::BoseEinstein;
let rdr = csv::Reader::from_path("test/data/number_density_massive.csv").unwrap();
let data: Vec<Row7> = rdr.into_deserialize()
let rdr = csv::Reader::from_path("test/data/number_density_massless.csv").unwrap();
let data: Vec<Row6> = rdr.into_deserialize()
.step_by(STEP_SIZE)
.map(|r| r.unwrap())
.collect();

b.iter(|| {
for &(_, mu, beta, _, _, _, _) in &data {
for &(mu, beta, _, _, _, _) in &data {
let n = be.massless_number_density(mu, beta);
black_box(n);
}
Expand All @@ -420,14 +421,14 @@ mod bench {
#[bench]
fn maxwell_boltzmann_massless(b: &mut Bencher) {
let mb = Statistic::MaxwellBoltzmann;
let rdr = csv::Reader::from_path("test/data/number_density_massive.csv").unwrap();
let data: Vec<Row7> = rdr.into_deserialize()
let rdr = csv::Reader::from_path("test/data/number_density_massless.csv").unwrap();
let data: Vec<Row6> = rdr.into_deserialize()
.step_by(STEP_SIZE)
.map(|r| r.unwrap())
.collect();

b.iter(|| {
for &(_, mu, beta, _, _, _, _) in &data {
for &(mu, beta, _, _, _, _) in &data {
let n = mb.massless_number_density(mu, beta);
black_box(n);
}
Expand All @@ -437,14 +438,14 @@ mod bench {
#[bench]
fn maxwell_juttner_massless(b: &mut Bencher) {
let mj = Statistic::MaxwellJuttner;
let rdr = csv::Reader::from_path("test/data/number_density_massive.csv").unwrap();
let data: Vec<Row7> = rdr.into_deserialize()
let rdr = csv::Reader::from_path("test/data/number_density_massless.csv").unwrap();
let data: Vec<Row6> = rdr.into_deserialize()
.step_by(STEP_SIZE)
.map(|r| r.unwrap())
.collect();

b.iter(|| {
for &(_, mu, beta, _, _, _, _) in &data {
for &(mu, beta, _, _, _, _) in &data {
let n = mj.massless_number_density(mu, beta);
black_box(n);
}
Expand Down

0 comments on commit ad265c5

Please sign in to comment.