update dependencies

This commit is contained in:
Magnus Ulimoen 2019-11-07 20:36:03 +01:00
parent bb5d7b1e38
commit 6058eae076
3 changed files with 25 additions and 15 deletions

View File

@ -11,17 +11,18 @@ crate-type = ["cdylib", "rlib"]
default = ["console_error_panic_hook", "wee_alloc"] default = ["console_error_panic_hook", "wee_alloc"]
[dependencies] [dependencies]
wasm-bindgen = "*" wasm-bindgen = "0.2.54"
console_error_panic_hook = { version = "*", optional = true } console_error_panic_hook = { version = "0.1.6", optional = true }
wee_alloc = { version = "*", optional = true } wee_alloc = { version = "0.4.5", optional = true }
ndarray = "0.12.1" ndarray = { version = "0.13.0", features = ["approx"] }
approx = "0.3.2"
[profile.release] [profile.release]
opt-level = 3 opt-level = 3
lto = "thin" lto = "thin"
[dev-dependencies] [dev-dependencies]
criterion = "0.3" criterion = "0.3.0"
[[bench]] [[bench]]
name = "system" name = "system"

View File

@ -1,19 +1,28 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion}; use criterion::{black_box, criterion_group, criterion_main, Criterion};
use maxwell::Universe; use maxwell::Universe;
fn simple_system(w: u32, h: u32) -> Universe { fn advance_system(universe: &mut Universe, n: usize) {
let mut universe = Universe::new(w, h); for _ in 0..n {
universe.init(0.0, 0.0);
for _ in 0..100 {
universe.advance(0.01); universe.advance(0.01);
} }
universe
} }
fn performance_benchmark(c: &mut Criterion) { fn performance_benchmark(c: &mut Criterion) {
c.bench_function("complete system", |b| { let mut group = c.benchmark_group("System");
b.iter(|| simple_system(black_box(25), black_box(30))) group.sample_size(15);
let w = 35;
let h = 26;
let mut universe = Universe::new(w, h);
group.bench_function("advance", |b| {
b.iter(|| {
universe.init(0.0, 0.0);
advance_system(&mut universe, black_box(20))
})
}); });
group.finish();
} }
criterion_group!(benches, performance_benchmark); criterion_group!(benches, performance_benchmark);

View File

@ -96,7 +96,7 @@ fn upwind4_test() {
} }
res.fill(0.0); res.fill(0.0);
Upwind4::diff(source.view(), res.view_mut()); Upwind4::diff(source.view(), res.view_mut());
assert!(res.all_close(&target, 1e-4)); approx::assert_abs_diff_eq!(&res, &target, epsilon = 1e-4);
for i in 0..nx { for i in 0..nx {
let x = i as f32 * dx; let x = i as f32 * dx;
@ -105,7 +105,7 @@ fn upwind4_test() {
} }
res.fill(0.0); res.fill(0.0);
Upwind4::diff(source.view(), res.view_mut()); Upwind4::diff(source.view(), res.view_mut());
assert!(res.all_close(&target, 1e-4)); approx::assert_abs_diff_eq!(&res, &target, epsilon = 1e-4);
for i in 0..nx { for i in 0..nx {
let x = i as f32 * dx; let x = i as f32 * dx;
@ -114,7 +114,7 @@ fn upwind4_test() {
} }
res.fill(0.0); res.fill(0.0);
Upwind4::diff(source.view(), res.view_mut()); Upwind4::diff(source.view(), res.view_mut());
assert!(res.all_close(&target, 1e-2)); approx::assert_abs_diff_eq!(&res, &target, epsilon = 1e-2);
} }
impl SbpOperator for Upwind4 { impl SbpOperator for Upwind4 {