-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
133 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,49 @@ | ||
use criterion::{black_box, Criterion}; | ||
use gammalg::bezier::BezierCurve; | ||
use crate::common::samples::CURVES; | ||
|
||
macro_rules! bench_curve_types { | ||
($group:ident, $body:expr) => { | ||
$group.bench_function("linear", |b| { | ||
for curve in CURVES.LINEAR.iter() { | ||
b.iter(|| $body(curve)) | ||
} | ||
}); | ||
$group.bench_function("quadratic", |b| { | ||
for curve in CURVES.QUADRATIC.iter() { | ||
b.iter(|| $body(curve)) | ||
} | ||
}); | ||
$group.bench_function("cubic", |b| { | ||
for curve in CURVES.CUBIC.iter() { | ||
b.iter(|| $body(curve)) | ||
} | ||
}); | ||
$group.bench_function("higher", |b| { | ||
for curve in CURVES.HIGHER.iter() { | ||
b.iter(|| $body(curve)) | ||
} | ||
}); | ||
} | ||
} | ||
|
||
pub fn split(c: &mut Criterion) { | ||
c.bench_function("split", |b| { | ||
for curve in CURVES.iter() { | ||
b.iter(|| black_box(curve.split(0.5))) | ||
} | ||
}); | ||
let mut g = c.benchmark_group("BezierCurve::split"); | ||
bench_curve_types!(g, |curve: &BezierCurve<f64>| curve.split(black_box(0.5))); | ||
} | ||
|
||
pub fn eval(c: &mut Criterion) { | ||
c.bench_function("eval", |b| { | ||
for curve in CURVES.iter() { | ||
b.iter(|| black_box(curve.castlejau_eval(0.5))) | ||
} | ||
}); | ||
pub fn castlejau_eval(c: &mut Criterion) { | ||
let mut g = c.benchmark_group("BezierCurve::castlejau_eval"); | ||
bench_curve_types!(g, |curve: &BezierCurve<f64>| curve.castlejau_eval(black_box(0.5))); | ||
} | ||
|
||
pub fn normal(c: &mut Criterion) { | ||
c.bench_function("normal", |b| { | ||
for curve in CURVES.iter() { | ||
b.iter(|| black_box(curve.normal(0.5))) | ||
} | ||
}); | ||
let mut g = c.benchmark_group("BezierCurve::normal"); | ||
bench_curve_types!(g, |curve: &BezierCurve<f64>| curve.normal(black_box(0.5))); | ||
} | ||
|
||
pub fn all(c: &mut Criterion) { | ||
split(c); | ||
eval(c); | ||
castlejau_eval(c); | ||
normal(c); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
use std::time::Duration; | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use pprof::criterion::{PProfProfiler, Output}; | ||
mod common; | ||
|
||
static SECOND: Duration = Duration::from_secs(1); | ||
criterion_group!{ | ||
name = benches; | ||
config = Criterion::default().with_profiler(PProfProfiler::new(100, Output::Flamegraph(None))); | ||
config = Criterion::default() | ||
.with_profiler(PProfProfiler::new(100, Output::Flamegraph(None))) | ||
; | ||
targets = common::bezier::all | ||
} | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
use std::time::Duration; | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
mod common; | ||
|
||
static SECOND: Duration = Duration::from_secs(1); | ||
criterion_group!{ | ||
name = benches; | ||
config = Criterion::default(); | ||
config = Criterion::default() | ||
.warm_up_time(SECOND) | ||
.measurement_time(SECOND) | ||
; | ||
targets = common::bezier::all | ||
} | ||
criterion_main!(benches); |