add benchmark
This commit is contained in:
parent
8a8e2fefec
commit
bb5d7b1e38
|
@ -19,3 +19,11 @@ ndarray = "0.12.1"
|
||||||
[profile.release]
|
[profile.release]
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
lto = "thin"
|
lto = "thin"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
criterion = "0.3"
|
||||||
|
|
||||||
|
[[bench]]
|
||||||
|
name = "system"
|
||||||
|
path = "src/benches/bench.rs"
|
||||||
|
harness = false
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||||
|
use maxwell::Universe;
|
||||||
|
|
||||||
|
fn simple_system(w: u32, h: u32) -> Universe {
|
||||||
|
let mut universe = Universe::new(w, h);
|
||||||
|
universe.init(0.0, 0.0);
|
||||||
|
for _ in 0..100 {
|
||||||
|
universe.advance(0.01);
|
||||||
|
}
|
||||||
|
universe
|
||||||
|
}
|
||||||
|
|
||||||
|
fn performance_benchmark(c: &mut Criterion) {
|
||||||
|
c.bench_function("complete system", |b| {
|
||||||
|
b.iter(|| simple_system(black_box(25), black_box(30)))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
criterion_group!(benches, performance_benchmark);
|
||||||
|
criterion_main!(benches);
|
Loading…
Reference in New Issue