BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
WallclockTimer Class Reference
Collaboration diagram for WallclockTimer:

Public Member Functions

 WallclockTimer ()
 
 ~WallclockTimer ()
 
void start ()
 
void stop ()
 
double runTime () const
 

Private Attributes

std::unique_ptr< WallclockTimerStatem_state
 

Detailed Description

A timer for measuring real (wall-clock) time spent between 'start' and 'stop' commands.

Definition at line 24 of file WallclockTimer.h.

Constructor & Destructor Documentation

◆ WallclockTimer()

WallclockTimer::WallclockTimer ( )

Definition at line 29 of file WallclockTimer.cpp.

std::unique_ptr< WallclockTimerState > m_state
Internal state of a WallclockTimer object.

◆ ~WallclockTimer()

WallclockTimer::~WallclockTimer ( )
default

Member Function Documentation

◆ start()

void WallclockTimer::start ( )

Definition at line 32 of file WallclockTimer.cpp.

33 {
34  m_state->m_is_running = true;
35  m_state->m_start_time = clock_used::now();
36 }

References m_state.

Referenced by Fit::Kernel::minimize(), FitPrintService::print(), and FitPrintService::wallTimeString().

◆ stop()

void WallclockTimer::stop ( )

Definition at line 38 of file WallclockTimer.cpp.

39 {
40  m_state->m_is_running = false;
41  m_state->m_end_time = clock_used::now();
42 }

References m_state.

Referenced by FitPrintService::fitResultString(), Fit::Kernel::minimize(), and FitPrintService::wallTimeString().

◆ runTime()

double WallclockTimer::runTime ( ) const

returns run time in sec.

Definition at line 44 of file WallclockTimer.cpp.

45 {
46  duration_unit diff =
47  m_state->m_is_running
48  ? std::chrono::duration_cast<duration_unit>(clock_used::now() - m_state->m_start_time)
49  : std::chrono::duration_cast<duration_unit>(m_state->m_end_time
50  - m_state->m_start_time);
51 
52  return (double)diff.count();
53 }
std::chrono::seconds duration_unit

References m_state.

Referenced by FitPrintService::fitResultString(), Fit::Kernel::minimize(), and FitPrintService::wallTimeString().

Member Data Documentation

◆ m_state

std::unique_ptr<WallclockTimerState> WallclockTimer::m_state
private

Definition at line 37 of file WallclockTimer.h.

Referenced by runTime(), start(), and stop().


The documentation for this class was generated from the following files: