mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
adding back files to be reviewed
This commit is contained in:
parent
ae28233110
commit
bc09d1ef55
1244 changed files with 301904 additions and 0 deletions
67
include/openmc/timer.h
Normal file
67
include/openmc/timer.h
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
#ifndef OPENMC_TIMER_H
|
||||
#define OPENMC_TIMER_H
|
||||
|
||||
#include <chrono>
|
||||
|
||||
namespace openmc {
|
||||
|
||||
//==============================================================================
|
||||
// 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;
|
||||
extern Timer time_read_xs;
|
||||
extern Timer time_tallies;
|
||||
extern Timer time_total;
|
||||
extern Timer time_transport;
|
||||
|
||||
} // namespace simulation
|
||||
|
||||
//==============================================================================
|
||||
//! Class for measuring time elapsed
|
||||
//==============================================================================
|
||||
|
||||
class Timer {
|
||||
public:
|
||||
using clock = std::chrono::high_resolution_clock;
|
||||
|
||||
Timer() {};
|
||||
|
||||
//! Start running the timer
|
||||
void start();
|
||||
|
||||
//! 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
|
||||
double elapsed_ {0.0}; //!< elapsed time in [s]
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
// Non-member functions
|
||||
//==============================================================================
|
||||
|
||||
void reset_timers();
|
||||
|
||||
} // namespace openmc
|
||||
|
||||
#endif // OPENMC_TIMER_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue