ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
JetTrigTimer Class Reference

#include <JetTrigTimer.h>

Collaboration diagram for JetTrigTimer:

Public Member Functions

 JetTrigTimer (bool nanoseconds=false)
 
void start ()
 
void update ()
 
std::string read () const
 
std::tuple< double, int, std::string > read_bare () const
 
void reset () noexcept
 
std::string readAndReset ()
 
double elapsed_to_now ()
 
double elapsed_to_update ()
 
std::string units () const
 

Private Member Functions

void accumulate ()
 

Private Attributes

std::size_t m_nCalls {0}
 
std::chrono::system_clock::time_point m_start
 
std::chrono::system_clock::time_point m_stop
 
double m_elapsedDelta {0.}
 
bool m_nanoseconds
 

Detailed Description

Definition at line 13 of file JetTrigTimer.h.

Constructor & Destructor Documentation

◆ JetTrigTimer()

JetTrigTimer::JetTrigTimer ( bool  nanoseconds = false)

Definition at line 13 of file JetTrigTimer.cxx.

13 : m_nanoseconds(ns) {}

Member Function Documentation

◆ accumulate()

void JetTrigTimer::accumulate ( )
private

◆ elapsed_to_now()

double JetTrigTimer::elapsed_to_now ( )

Definition at line 74 of file JetTrigTimer.cxx.

74  {
75  update();
77  return m_elapsedDelta;
78 }

◆ elapsed_to_update()

double JetTrigTimer::elapsed_to_update ( )

Definition at line 80 of file JetTrigTimer.cxx.

80  {
81  // update the current data, return the time since start()
82  return m_elapsedDelta;
83 }

◆ read()

std::string JetTrigTimer::read ( ) const

Definition at line 45 of file JetTrigTimer.cxx.

45  {
46  // reuturn curent data as a string
47 
48  auto record = read_bare();
49  auto delta = std::get<0>(record);
50  auto ncalls = std::get<1>(record);
51  auto units = std::get<2>(record);
52 
53  std::stringstream ss;
54  double avTime = ncalls == 0 ? 0. : delta / m_nCalls;
55  ss << "time("<<units <<"): " << delta << " nCalls: " << ncalls << " tav: "
56  << avTime;
57  return ss.str();
58 }

◆ read_bare()

std::tuple< double, int, std::string > JetTrigTimer::read_bare ( ) const

Definition at line 60 of file JetTrigTimer.cxx.

60  {
61  // reuturn curent data in numeric form
62 
63  return std::make_tuple(m_elapsedDelta, m_nCalls, units());
64 }

◆ readAndReset()

std::string JetTrigTimer::readAndReset ( )

Definition at line 66 of file JetTrigTimer.cxx.

66  {
67  // obtain current data as a string then reset the timer
68  auto s = read();
69  reset();
70  return s;
71 }

◆ reset()

void JetTrigTimer::reset ( )
noexcept

Definition at line 35 of file JetTrigTimer.cxx.

35  {
36  // general reset
37 
38  m_nCalls = 0;
39  m_elapsedDelta = 0.;
40  m_nCalls = 0;
42  m_stop = m_start;
43 }

◆ start()

void JetTrigTimer::start ( )

Definition at line 15 of file JetTrigTimer.cxx.

15  {
16  // reset start time to now
17 
18  m_nCalls += 1;
20 }

◆ units()

std::string JetTrigTimer::units ( ) const

Definition at line 86 of file JetTrigTimer.cxx.

86  {
87  return m_nanoseconds ? "ns" : "us";
88 }

◆ update()

void JetTrigTimer::update ( )

Definition at line 22 of file JetTrigTimer.cxx.

22  {
23  // reset stop time to now, calculate delta and sum delta.
24  // does not change the start time
25 
27  if(m_nanoseconds){
28  m_elapsedDelta += duration_cast<nanoseconds>(m_stop - m_start).count();
29  } else {
30  m_elapsedDelta += duration_cast<microseconds>(m_stop - m_start).count();
31  }
32 }

Member Data Documentation

◆ m_elapsedDelta

double JetTrigTimer::m_elapsedDelta {0.}
private

Definition at line 32 of file JetTrigTimer.h.

◆ m_nanoseconds

bool JetTrigTimer::m_nanoseconds
private

Definition at line 33 of file JetTrigTimer.h.

◆ m_nCalls

std::size_t JetTrigTimer::m_nCalls {0}
private

Definition at line 28 of file JetTrigTimer.h.

◆ m_start

std::chrono::system_clock::time_point JetTrigTimer::m_start
private

Definition at line 29 of file JetTrigTimer.h.

◆ m_stop

std::chrono::system_clock::time_point JetTrigTimer::m_stop
private

Definition at line 30 of file JetTrigTimer.h.


The documentation for this class was generated from the following files:
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
JetTrigTimer::read_bare
std::tuple< double, int, std::string > read_bare() const
Definition: JetTrigTimer.cxx:60
JetTrigTimer::m_nCalls
std::size_t m_nCalls
Definition: JetTrigTimer.h:28
JetTrigTimer::read
std::string read() const
Definition: JetTrigTimer.cxx:45
JetTrigTimer::m_stop
std::chrono::system_clock::time_point m_stop
Definition: JetTrigTimer.h:30
JetTrigTimer::m_start
std::chrono::system_clock::time_point m_start
Definition: JetTrigTimer.h:29
JetTrigTimer::units
std::string units() const
Definition: JetTrigTimer.cxx:86
JetTrigTimer::update
void update()
Definition: JetTrigTimer.cxx:22
python.handimod.now
now
Definition: handimod.py:675
JetTrigTimer::m_elapsedDelta
double m_elapsedDelta
Definition: JetTrigTimer.h:32
JetTrigTimer::reset
void reset() noexcept
Definition: JetTrigTimer.cxx:35
JetTrigTimer::m_nanoseconds
bool m_nanoseconds
Definition: JetTrigTimer.h:33
python.SystemOfUnits.ns
int ns
Definition: SystemOfUnits.py:130