ATLAS Offline Software
Loading...
Searching...
No Matches
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();
76 m_start = system_clock::now();
77 return m_elapsedDelta;
78}
double m_elapsedDelta
std::chrono::system_clock::time_point m_start

◆ 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 const 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}
static Double_t ss
std::string units() const
std::size_t m_nCalls
std::tuple< double, int, std::string > read_bare() const

◆ 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}
std::string read() const
void reset() noexcept

◆ 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;
41 m_start = std::chrono::system_clock::now();
43}
std::chrono::system_clock::time_point m_stop

◆ start()

void JetTrigTimer::start ( )

Definition at line 15 of file JetTrigTimer.cxx.

15 {
16 // reset start time to now
17
18 m_nCalls += 1;
19 m_start = system_clock::now();
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
26 m_stop = system_clock::now();
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.

32{0.};

◆ 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.

28{0};

◆ 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: