2018-10-12 07:03:20 -05:00
|
|
|
#ifndef OPENMC_TIMER_H
|
|
|
|
|
#define OPENMC_TIMER_H
|
|
|
|
|
|
|
|
|
|
#include <chrono>
|
|
|
|
|
|
|
|
|
|
namespace openmc {
|
|
|
|
|
|
2018-11-08 15:36:19 -06:00
|
|
|
//==============================================================================
|
|
|
|
|
// Global variables
|
|
|
|
|
//==============================================================================
|
|
|
|
|
|
|
|
|
|
class Timer;
|
|
|
|
|
|
|
|
|
|
namespace simulation {
|
|
|
|
|
|
|
|
|
|
extern Timer time_active;
|
|
|
|
|
extern Timer time_bank;
|
|
|
|
|
extern Timer time_bank_sample;
|
|
|
|
|
extern Timer time_bank_sendrecv;
|
|
|
|
|
extern Timer time_finalize;
|
|
|
|
|
extern Timer time_inactive;
|
|
|
|
|
extern Timer time_initialize;
|
2019-01-23 10:35:28 -06:00
|
|
|
extern Timer time_read_xs;
|
2020-09-16 16:44:20 -05:00
|
|
|
extern Timer time_statepoint;
|
2018-11-08 15:36:19 -06:00
|
|
|
extern Timer time_tallies;
|
|
|
|
|
extern Timer time_total;
|
|
|
|
|
extern Timer time_transport;
|
2020-01-19 21:02:40 +00:00
|
|
|
extern Timer time_event_init;
|
|
|
|
|
extern Timer time_event_calculate_xs;
|
|
|
|
|
extern Timer time_event_advance_particle;
|
|
|
|
|
extern Timer time_event_surface_crossing;
|
|
|
|
|
extern Timer time_event_collision;
|
|
|
|
|
extern Timer time_event_death;
|
2018-11-08 15:36:19 -06:00
|
|
|
|
|
|
|
|
} // namespace simulation
|
|
|
|
|
|
2018-10-12 07:03:20 -05:00
|
|
|
//==============================================================================
|
|
|
|
|
//! Class for measuring time elapsed
|
|
|
|
|
//==============================================================================
|
|
|
|
|
|
|
|
|
|
class Timer {
|
|
|
|
|
public:
|
|
|
|
|
using clock = std::chrono::high_resolution_clock;
|
|
|
|
|
|
|
|
|
|
Timer() {};
|
|
|
|
|
|
|
|
|
|
//! Start running the timer
|
2018-12-19 12:04:51 -05:00
|
|
|
void start();
|
2018-10-12 07:03:20 -05:00
|
|
|
|
|
|
|
|
//! Get total elapsed time in seconds
|
|
|
|
|
//! \return Elapsed time in [s]
|
|
|
|
|
double elapsed();
|
|
|
|
|
|
|
|
|
|
//! Stop running the timer
|
|
|
|
|
void stop();
|
|
|
|
|
|
|
|
|
|
//! Stop the timer and reset its elapsed time
|
|
|
|
|
void reset();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
bool running_ {false}; //!< is timer running?
|
|
|
|
|
std::chrono::time_point<clock> start_; //!< starting point for clock
|
2018-12-19 12:04:51 -05:00
|
|
|
double elapsed_ {0.0}; //!< elapsed time in [s]
|
2018-10-12 07:03:20 -05:00
|
|
|
};
|
|
|
|
|
|
2018-10-17 17:04:32 -05:00
|
|
|
//==============================================================================
|
|
|
|
|
// Non-member functions
|
|
|
|
|
//==============================================================================
|
|
|
|
|
|
|
|
|
|
void reset_timers();
|
|
|
|
|
|
2018-10-12 07:03:20 -05:00
|
|
|
} // namespace openmc
|
|
|
|
|
|
|
|
|
|
#endif // OPENMC_TIMER_H
|