Skip to content

Commit

Permalink
rename Timers -> Performance
Browse files Browse the repository at this point in the history
  • Loading branch information
Tehforsch committed Sep 15, 2023
1 parent c36b472 commit f9442ae
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/io/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use crate::communication::Rank;
use crate::communication::SizedCommunicator;
use crate::hash_map::HashMap;
use crate::io::DatasetShape;
use crate::performance_data::Timers;
use crate::performance::Performance;
use crate::prelude::Float;
use crate::prelude::LocalParticle;
use crate::prelude::Named;
Expand Down Expand Up @@ -310,7 +310,7 @@ fn spawn_entities_system(
mut spawned_entities: ResMut<SpawnedEntities>,
datasets: Res<RegisteredDatasets>,
parameters: Res<InputParameters>,
mut performance_data: ResMut<Timers>,
mut performance_data: ResMut<Performance>,
) {
let reader = Reader::split_between_ranks(parameters.all_input_files());
if datasets.len() == 0 {
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ mod parameter_plugin;
pub mod parameters;
mod particle;
mod peano_hilbert;
mod performance_data;
mod performance;
pub mod prelude;
pub mod quadtree;
mod simulation;
Expand Down
8 changes: 4 additions & 4 deletions src/performance_data.rs → src/performance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ impl Timer {
}

#[derive(Resource, Default, Debug, Serialize)]
pub struct Timers {
pub struct Performance {
results: HashMap<Category, Result>,
#[serde(skip)]
timers: HashMap<Category, Timer>,
}

impl Timers {
impl Performance {
pub fn start<N: Into<String>>(&mut self, name: N) {
self.timers.insert(name.into(), Timer::default());
}
Expand Down Expand Up @@ -152,7 +152,7 @@ impl Timers {

#[must_use = "A timer guard needs to be used."]
pub struct TimerGuard<'a, N: Into<String> + Clone> {
data: &'a mut Timers,
data: &'a mut Performance,
name: N,
}

Expand All @@ -163,7 +163,7 @@ impl<'a, N: Into<String> + Clone> Drop for TimerGuard<'a, N> {
}

pub fn write_performance_data_system(
timers: NonSendMut<Timers>,
timers: NonSendMut<Performance>,
parameters: Res<OutputParameters>,
) {
fs::write(
Expand Down
10 changes: 5 additions & 5 deletions src/simulation_plugin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use crate::io::output::OutputPlugin;
use crate::named::Named;
use crate::parameters::SimulationBox;
use crate::particle::ParticlePlugin;
use crate::performance_data::write_performance_data_system;
use crate::performance_data::Timers;
use crate::performance::write_performance_data_system;
use crate::performance::Performance;
use crate::prelude::Particles;
use crate::prelude::WorldSize;
use crate::simulation::RaxiomPlugin;
Expand Down Expand Up @@ -59,7 +59,7 @@ pub struct StopSimulationEvent;

impl RaxiomPlugin for SimulationPlugin {
fn build_everywhere(&self, sim: &mut Simulation) {
let mut perf = Timers::default();
let mut perf = Performance::default();
perf.start("total");
sim.insert_non_send_resource(perf)
.add_parameter_type::<SimulationParameters>()
Expand Down Expand Up @@ -113,7 +113,7 @@ fn show_time_system(time: Res<SimulationTime>) {
fn exit_system(
mut evs: EventWriter<AppExit>,
mut stop_sim: EventReader<StopSimulationEvent>,
mut timers: NonSendMut<Timers>,
mut timers: NonSendMut<Performance>,
) {
if stop_sim.iter().count() > 0 {
timers.stop("total");
Expand All @@ -123,7 +123,7 @@ fn exit_system(
}
}

fn show_num_cores_system(world_size: Res<WorldSize>, mut performance_data: ResMut<Timers>) {
fn show_num_cores_system(world_size: Res<WorldSize>, mut performance_data: ResMut<Performance>) {
performance_data.record_number("num_ranks", **world_size);
info!("Running on {} MPI ranks", **world_size);
}
Expand Down
6 changes: 3 additions & 3 deletions src/stages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use bevy_ecs::prelude::*;
use bevy_ecs::schedule::ShouldRun;
use bevy_ecs::schedule::StageLabelId;

use crate::performance_data::Timers;
use crate::performance::Performance;
use crate::simulation_plugin::Stages;
use crate::simulation_plugin::StartupStages;

Expand Down Expand Up @@ -116,10 +116,10 @@ fn add_stage_timers_for_stages(schedule: &mut Schedule, stages: &[StageLabelId])
for window in stages.windows(3) {
let (s1, s2, s3) = (window[0], window[1], window[2]);
if !is_timer_stage(s2) {
schedule.add_system_to_stage(s1, move |mut timers: ResMut<Timers>| {
schedule.add_system_to_stage(s1, move |mut timers: ResMut<Performance>| {
timers.start(s2.as_str());
});
schedule.add_system_to_stage(s3, move |mut timers: ResMut<Timers>| {
schedule.add_system_to_stage(s3, move |mut timers: ResMut<Performance>| {
timers.stop(s2.as_str());
});
}
Expand Down
12 changes: 6 additions & 6 deletions src/sweep/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ use crate::io::time_series::TimeSeriesPlugin;
use crate::io::to_dataset::ToDataset;
use crate::particle::HaloParticles;
use crate::particle::ParticleId;
use crate::performance_data::Timers;
use crate::performance::Performance;
use crate::prelude::*;
use crate::simulation::RaxiomPlugin;
use crate::simulation_plugin::SimulationTime;
Expand Down Expand Up @@ -235,7 +235,7 @@ impl<C: Chemistry> Sweep<C> {
}
}

pub fn run_sweeps(&mut self, timers: &mut Timers) -> Time {
pub fn run_sweeps(&mut self, timers: &mut Performance) -> Time {
let counts = self.get_cell_counts_per_level();
self.print_cell_counts(&counts);
for level in self.timestep_state.iter_levels_in_sweep_order() {
Expand All @@ -251,7 +251,7 @@ impl<C: Chemistry> Sweep<C> {
time_elapsed
}

fn single_sweep(&mut self, timers: &mut Timers) {
fn single_sweep(&mut self, timers: &mut Performance) {
timers.start(self.current_level);
trace!("Level {:>2}: Sweeping.", self.current_level.0);
self.init_counts();
Expand Down Expand Up @@ -521,7 +521,7 @@ impl<C: Chemistry> Sweep<C> {
}
}

fn update_chemistry(&mut self, timers: &mut Timers) {
fn update_chemistry(&mut self, timers: &mut Performance) {
let _timer = timers.time("chemistry");
for (id, cell) in self.cells.enumerate_active(self.current_level) {
let (level, site) = self.sites.get_mut_with_level(id);
Expand All @@ -548,7 +548,7 @@ impl<C: Chemistry> Sweep<C> {
}
}

fn update_timestep_levels(&mut self, timers: &mut Timers) {
fn update_timestep_levels(&mut self, timers: &mut Performance) {
let _timer = timers.time("update levels");
for (id, level, site) in self.sites.enumerate_with_levels_mut() {
let desired_timestep = self.timestep_safety_factor * site.change_timescale;
Expand Down Expand Up @@ -655,7 +655,7 @@ fn run_sweep_system(
mut ionization_times: Particles<(&ParticleId, &mut IonizationTime)>,
mut rates: Particles<(&ParticleId, &mut components::PhotonRate)>,
mut time: ResMut<SimulationTime>,
mut timers: NonSendMut<Timers>,
mut timers: NonSendMut<Performance>,
) {
let solver = (*solver).as_mut().unwrap();
let time_elapsed = solver.run_sweeps(&mut timers);
Expand Down

0 comments on commit f9442ae

Please sign in to comment.