-
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.
* fix clippy warnings in test * Removed useless loop statement in main * highlight code with poor memory usage * change in snap turtle implem Now uses clamp() method; no perf diff but readability increased * added check for particle density * better MCGeneralPlane constructor * moved mc_vector tests back to the src file * removed dead code & simplified get_total_cross_section method * small changes in tallies mod * removed misc test those did not concern fastiron, just verification of how Rust works * added a match statement to handle CpuBindError the bind doesn't work on m1 chip apparently * small changes in simulation module * renamed io_utils mod to input * version bump + dependencies update * fixed doc warning * fixed cargo warning * fixed doc example
- Loading branch information
Showing
25 changed files
with
779 additions
and
749 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,5 +1,6 @@ | ||
[workspace] | ||
|
||
resolver= "2" | ||
members = ["fastiron", "fastiron-stats"] | ||
|
||
[profile.release] | ||
|
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,11 +1,11 @@ | ||
[package] | ||
name = "fastiron-stats" | ||
version = "1.1.0" | ||
version = "1.1.1" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
clap = {version="4.3.5", features=["cargo", "derive"]} | ||
csv = "1.2.2" | ||
gnuplot = "0.0.38" | ||
clap = { version = "*", features = ["cargo", "derive"] } | ||
csv = "*" | ||
gnuplot = "*" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion}; | ||
use fastiron::constants::Tuple3; | ||
|
||
// Define the routines that are tested | ||
|
||
fn manual_snap(times: usize) { | ||
let bounds: (usize, usize, usize) = (10, 10, 10); | ||
fn snap(bounds: (usize, usize, usize), tt: (i32, i32, i32)) -> Tuple3 { | ||
( | ||
(tt.0.max(0) as usize).min(bounds.0 - 1), | ||
(tt.1.max(0) as usize).min(bounds.1 - 1), | ||
(tt.2.max(0) as usize).min(bounds.2 - 1), | ||
) | ||
} | ||
let tt1 = (1, 3, 2); // nothing to snap | ||
let tt2 = (-1, 3, 2); // 1 element | ||
let tt3 = (-1, 11, 2); // 2 elements | ||
let tt4 = (-1, 11, -1); // 3 elements | ||
(0..times).for_each(|_| { | ||
let res = snap(bounds, tt1); | ||
black_box(res); | ||
}); | ||
(0..times).for_each(|_| { | ||
let res = snap(bounds, tt2); | ||
black_box(res); | ||
}); | ||
(0..times).for_each(|_| { | ||
let res = snap(bounds, tt3); | ||
black_box(res); | ||
}); | ||
(0..times).for_each(|_| { | ||
let res = snap(bounds, tt4); | ||
black_box(res); | ||
}); | ||
} | ||
|
||
fn clamp_snap(times: usize) { | ||
let bounds: (usize, usize, usize) = (10, 10, 10); | ||
fn snap(bounds: (usize, usize, usize), tt: (i32, i32, i32)) -> Tuple3 { | ||
( | ||
tt.0.clamp(0, (bounds.0 - 1) as i32) as usize, | ||
tt.1.clamp(0, (bounds.1 - 1) as i32) as usize, | ||
tt.2.clamp(0, (bounds.2 - 1) as i32) as usize, | ||
) | ||
} | ||
let tt1 = (1, 3, 2); // nothing to snap | ||
let tt2 = (-1, 3, 2); // 1 element | ||
let tt3 = (-1, 11, 2); // 2 elements | ||
let tt4 = (-1, 11, -1); // 3 elements | ||
(0..times).for_each(|_| { | ||
let res = snap(bounds, tt1); | ||
black_box(res); | ||
}); | ||
(0..times).for_each(|_| { | ||
let res = snap(bounds, tt2); | ||
black_box(res); | ||
}); | ||
(0..times).for_each(|_| { | ||
let res = snap(bounds, tt3); | ||
black_box(res); | ||
}); | ||
(0..times).for_each(|_| { | ||
let res = snap(bounds, tt4); | ||
black_box(res); | ||
}); | ||
} | ||
|
||
pub fn criterion_benchmark(c: &mut Criterion) { | ||
// Generate/Define the input | ||
let n_iter: usize = 1000; | ||
|
||
let mut group = c.benchmark_group("snap turtle implementation"); | ||
group.bench_with_input( | ||
BenchmarkId::new("manual snap", "number of iterations/4"), | ||
&n_iter, | ||
|b, &n| b.iter(|| manual_snap(n)), | ||
); | ||
group.bench_with_input( | ||
BenchmarkId::new("clamp snap", "number of iterations/4"), | ||
&n_iter, | ||
|b, &n| b.iter(|| clamp_snap(n)), | ||
); | ||
group.finish(); | ||
} | ||
|
||
criterion_group!(benches, criterion_benchmark); | ||
criterion_main!(benches); |
Oops, something went wrong.