VM2D 1.14
Vortex methods for 2D flows simulation
Loading...
Searching...
No Matches
VMlib::vmTimer Class Reference

Класс засекания времени More...

#include <TimesGen.h>

Collaboration diagram for VMlib::vmTimer:

Public Types

using ms = std::chrono::duration< float, std::chrono::milliseconds::period >
 Основная единица измерения времени — миллисекунды
 
using s = std::chrono::duration< float, std::chrono::seconds::period >
 Дополнительная единица измерения времени — секунды
 

Public Member Functions

 vmTimer (const std::string &timerLabel="")
 Конструктор, принимающий на вход имя счетчика
 
 ~vmTimer ()=default
 
const vmTimerreset () const
 Сброс счетчика времени
 
const vmTimerstart () const
 Запуск (первый или повторный) счетчика времени
 
const vmTimerstop () const
 Останов работающего счетчика времени
 
template<typename T = ms>
double duration () const
 

Private Types

using Clock = std::chrono::high_resolution_clock
 

Private Member Functions

 vmTimer (const vmTimer &)=delete
 
vmTimeroperator= (const vmTimer &)=delete
 

Private Attributes

const std::string label
 Имя счетчика времени
 
bool active = false
 Признак того, что счетчик работает
 
std::chrono::duration< float > duration_
 Хранит накопденную от предыдущих запусков продолжительность работы счетчика
 
Clock::time_point start_ = Clock::now()
 Отметка последнего включения счетчика
 
Clock::time_point stop_ = Clock::now()
 Отметка последнего выключения счетчика
 

Detailed Description

Класс засекания времени

Author
Марчевский Илья Константинович \Version 1.14
Date
6 марта 2026 г.

Definition at line 58 of file TimesGen.h.

Member Typedef Documentation

◆ Clock

using VMlib::vmTimer::Clock = std::chrono::high_resolution_clock
private

Definition at line 63 of file TimesGen.h.

◆ ms

using VMlib::vmTimer::ms = std::chrono::duration<float, std::chrono::milliseconds::period>

Основная единица измерения времени — миллисекунды

Definition at line 88 of file TimesGen.h.

◆ s

using VMlib::vmTimer::s = std::chrono::duration<float, std::chrono::seconds::period>

Дополнительная единица измерения времени — секунды

Definition at line 91 of file TimesGen.h.

Constructor & Destructor Documentation

◆ vmTimer() [1/2]

VMlib::vmTimer::vmTimer ( const vmTimer )
privatedelete

◆ vmTimer() [2/2]

VMlib::vmTimer::vmTimer ( const std::string &  timerLabel = "")
inline

Конструктор, принимающий на вход имя счетчика

Создает счетчик, засекающий время в миллисекундах

Parameters
[in]timerLabelконстантная ссылка на строку — имя счетчика

Definition at line 97 of file TimesGen.h.

97: label(timerLabel) { reset(); }
const std::string label
Имя счетчика времени
Definition TimesGen.h:61
const vmTimer & reset() const
Сброс счетчика времени
Definition TimesGen.h:101
Here is the call graph for this function:

◆ ~vmTimer()

VMlib::vmTimer::~vmTimer ( )
default

Member Function Documentation

◆ duration()

template<typename T = ms>
double VMlib::vmTimer::duration ( ) const
inline

Definition at line 143 of file TimesGen.h.

144 {
145 return std::chrono::duration_cast<T>(duration_).count();
146 }
std::chrono::duration< float > duration_
Хранит накопденную от предыдущих запусков продолжительность работы счетчика
Definition TimesGen.h:69
Here is the caller graph for this function:

◆ operator=()

vmTimer & VMlib::vmTimer::operator= ( const vmTimer )
privatedelete

◆ reset()

const vmTimer & VMlib::vmTimer::reset ( ) const
inline

Сброс счетчика времени

Definition at line 101 of file TimesGen.h.

102 {
103 duration_ = std::chrono::seconds(0);
104 active = false;
105 return *this;
106 }
bool active
Признак того, что счетчик работает
Definition TimesGen.h:66
Here is the caller graph for this function:

◆ start()

const vmTimer & VMlib::vmTimer::start ( ) const
inline

Запуск (первый или повторный) счетчика времени

Definition at line 109 of file TimesGen.h.

110 {
111 if (!active)
112 {
113 start_ = Clock::now();
114 active = true;
115 }
116 else
117 {
118 std::cout << "Timer " << label << " was not stopped before being start!" << std::endl;
119 exit(-15);
120 }
121 return *this;
122 }
Clock::time_point start_
Отметка последнего включения счетчика
Definition TimesGen.h:72
Here is the caller graph for this function:

◆ stop()

const vmTimer & VMlib::vmTimer::stop ( ) const
inline

Останов работающего счетчика времени

Definition at line 125 of file TimesGen.h.

126 {
127 if (active)
128 {
129 stop_ = Clock::now();
131 active = false;
132 }
133 else
134 {
135 std::cout << "Timer " << label << " was not started before being stopped!" << std::endl;
136 exit(-15);
137 }
138 return *this;
139 }
Clock::time_point stop_
Отметка последнего выключения счетчика
Definition TimesGen.h:75
Here is the caller graph for this function:

Member Data Documentation

◆ active

bool VMlib::vmTimer::active = false
mutableprivate

Признак того, что счетчик работает

Definition at line 66 of file TimesGen.h.

◆ duration_

std::chrono::duration<float> VMlib::vmTimer::duration_
mutableprivate

Хранит накопденную от предыдущих запусков продолжительность работы счетчика

Definition at line 69 of file TimesGen.h.

◆ label

const std::string VMlib::vmTimer::label
private

Имя счетчика времени

Definition at line 61 of file TimesGen.h.

◆ start_

Clock::time_point VMlib::vmTimer::start_ = Clock::now()
mutableprivate

Отметка последнего включения счетчика

Definition at line 72 of file TimesGen.h.

◆ stop_

Clock::time_point VMlib::vmTimer::stop_ = Clock::now()
mutableprivate

Отметка последнего выключения счетчика

Definition at line 75 of file TimesGen.h.


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