-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve classics LHS performance (#138)
* Add bench for LHS classic * Respect the row layout and avoid final copy * Use column layout and avoid transpose, adjust test results * Adjust tests results * Rename bench classics * Remove useless allocation in centered LHS * Use column layout and avoid allocation for centered LHS * bench all lhs classics * Adjust py sampling test results * Relax test tolerance * Adjust test following LHS changes * Adjust constraint tolerance * Disable variance deriv test: too brittle, to be reworked
- Loading branch information
Showing
10 changed files
with
93 additions
and
59 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 |
---|---|---|
|
@@ -37,3 +37,7 @@ approx = "0.4" | |
[[bench]] | ||
name = "lhs" | ||
harness = false | ||
|
||
[[bench]] | ||
name = "lhs_classics" | ||
harness = false |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use criterion::{black_box, criterion_group, criterion_main, Criterion}; | ||
use egobox_doe::{Lhs, LhsKind, SamplingMethod}; | ||
use ndarray::aview1; | ||
|
||
fn criterion_lhs_classics(c: &mut Criterion) { | ||
let dims = [500]; | ||
let sizes = [1000]; | ||
let kinds = [LhsKind::Classic, LhsKind::Maximin, LhsKind::Centered]; | ||
|
||
let mut group = c.benchmark_group("doe"); | ||
group.sample_size(10); | ||
let arr1 = aview1(&[0., 1.]); | ||
for dim in dims { | ||
for size in sizes { | ||
for kind in kinds { | ||
group.bench_function(format!("lhs-{kind:?}-{dim}-dim-{size}-size"), |b| { | ||
let xlimits = arr1.broadcast((dim, 2)).unwrap(); | ||
b.iter(|| black_box(Lhs::new(&xlimits).kind(kind).sample(size))); | ||
}); | ||
} | ||
} | ||
} | ||
group.finish(); | ||
} | ||
|
||
criterion_group!(benches, criterion_lhs_classics); | ||
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
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
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
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
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