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

Класс для сбора статистики времени исполнения основных шагов алгоритма и вывода ее в файл More...

#include <TimesGen.h>

Collaboration diagram for VMlib::TimersGen:

Public Member Functions

 TimersGen (const WorldGen &W_, std::vector< std::string > labels)
 Конструктор
 
void start (const std::string &timerLabel)
 Запуск счетчика
 
void stop (const std::string &timerLabel)
 Останов счетчика
 
void resetAll ()
 Сброс всех счетчиков
 
template<typename T = vmTimer::s>
double durationStep () const
 Вывод счетчика всего шага в секундах
 
void GenerateStatHeader ()
 Формирование заголовка файла временной статистики
 
void GenerateStatString (size_t stepNo, double curTime, size_t N)
 Формирование очередной строки файла временной статистики
 

Protected Attributes

std::vector< std::string > timerLabelList
 Список имен счетчиков
 
std::map< std::string, std::unique_ptr< vmTimer > > timer
 Ассоциативный массив { имя, счетчик }.
 

Private Attributes

const WorldGenW
 Константная ссылка на решаемую задачу
 

Detailed Description

Класс для сбора статистики времени исполнения основных шагов алгоритма и вывода ее в файл

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

Definition at line 156 of file TimesGen.h.

Constructor & Destructor Documentation

◆ TimersGen()

TimersGen::TimersGen ( const WorldGen W_,
std::vector< std::string >  labels 
)

Конструктор

Definition at line 47 of file TimesGen.cpp.

48 : W(W_)
49{
50 timerLabelList = labels;
51 for (const auto& s : labels)
52 timer.insert({ s, std::make_unique<vmTimer>(s) });
53}//TimersGen(...)
std::vector< std::string > timerLabelList
Список имен счетчиков
Definition TimesGen.h:164
const WorldGen & W
Константная ссылка на решаемую задачу
Definition TimesGen.h:160
std::map< std::string, std::unique_ptr< vmTimer > > timer
Ассоциативный массив { имя, счетчик }.
Definition TimesGen.h:167

Member Function Documentation

◆ durationStep()

template<typename T = vmTimer::s>
double VMlib::TimersGen::durationStep ( ) const
inline

Вывод счетчика всего шага в секундах

Definition at line 184 of file TimesGen.h.

185 {
186 return (timer.at("Step"))->duration<T>();
187 }
Here is the caller graph for this function:

◆ GenerateStatHeader()

void TimersGen::GenerateStatHeader ( )

Формирование заголовка файла временной статистики

Definition at line 87 of file TimesGen.cpp.

88{
89 std::stringstream ss;
90 ss << std::setw(6) << "Step" << "" \
91 << std::setw(9) << "Time" << "" \
92 << std::setw(9) << "N" << "";
93
94 for (const auto& k : timerLabelList)
95 ss << std::setw(9) << k << "";
96
97 ss << std::setw(9) << "Other" << "";
98
99 std::stringstream timeStatFileName;
100 timeStatFileName << W.getPassportGen().dir << "timestat";
101
102 std::ofstream timeStatFile(timeStatFileName.str());
103 VMlib::PrintLogoToTextFile(timeStatFile, timeStatFileName.str(), "Time statistics (in milliseconds)");
104
105 VMlib::PrintHeaderToTextFile(timeStatFile, ss.str());
106
107 timeStatFile.close();
108 timeStatFile.clear();
109}//GenerateStatHeader()
std::string dir
Рабочий каталог задачи
const PassportGen & getPassportGen() const
Definition WorldGen.h:102
void PrintHeaderToTextFile(std::ofstream &str, const std::string &header)
Формирование подзаголовка в текстовом файле вывода программы VM2D/VM3D.
Definition defs.cpp:175
void PrintLogoToTextFile(std::ofstream &str, const std::string &fileName, const std::string &descr)
Формирование заголовка файла программы VM2D/VM3D.
Definition defs.cpp:139
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GenerateStatString()

void TimersGen::GenerateStatString ( size_t  stepNo,
double  curTime,
size_t  N 
)

Формирование очередной строки файла временной статистики

Definition at line 111 of file TimesGen.cpp.

112{
113 std::ofstream timestatFile(W.getPassportGen().dir + "timestat", std::ios::app);
114
115 std::stringstream ss;
116 ss << std::setw(9) << stepNo << "" \
117 << std::setw(9) << curTime << "" \
118 //<< std::setw(9) << N << "";
119 << std::setw(9) << W.nVtxBeforeMerging << "";
120 double tOther = 0.0;
121
122 ss.precision(2);
123 ss << std::fixed;
124
125 for (const auto& k : timerLabelList)
126 {
127 double duration = timer[k]->duration<vmTimer::ms>();
128 ss << std::setw(9) << duration << "";
129 tOther += (k == "Step" ? duration : -duration);
130 }
131 ss << std::setw(9) << tOther;
132
133 timestatFile << std::endl << ss.str();
134}
size_t nVtxBeforeMerging
Definition WorldGen.h:76
std::chrono::duration< float, std::chrono::milliseconds::period > ms
Основная единица измерения времени — миллисекунды
Definition TimesGen.h:88
Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetAll()

void TimersGen::resetAll ( )

Сброс всех счетчиков

Definition at line 81 of file TimesGen.cpp.

82{
83 for (auto& tmr_ : timer)
84 tmr_.second->reset();
85}//resetAll(...)
Here is the caller graph for this function:

◆ start()

void TimersGen::start ( const std::string &  timerLabel)

Запуск счетчика

Definition at line 55 of file TimesGen.cpp.

56{
57 try
58 {
59 timer.at(timerLabel)->start();
60 }
61 catch (...)
62 {
63 std::cout << "No timer \"" << timerLabel << "\" pre-determined!" << std::endl;
64 exit(-16);
65 }
66}//start(...)
Here is the caller graph for this function:

◆ stop()

void TimersGen::stop ( const std::string &  timerLabel)

Останов счетчика

Definition at line 68 of file TimesGen.cpp.

69{
70 try
71 {
72 timer.at(timerLabel)->stop();
73 }
74 catch (...)
75 {
76 std::cout << "No timer \"" << timerLabel << "\" pre-determined!" << std::endl;
77 exit(-16);
78 }
79}//stop(...)
Here is the caller graph for this function:

Member Data Documentation

◆ timer

std::map<std::string, std::unique_ptr<vmTimer> > VMlib::TimersGen::timer
protected

Ассоциативный массив { имя, счетчик }.

Definition at line 167 of file TimesGen.h.

◆ timerLabelList

std::vector<std::string> VMlib::TimersGen::timerLabelList
protected

Список имен счетчиков

Definition at line 164 of file TimesGen.h.

◆ W

const WorldGen& VMlib::TimersGen::W
private

Константная ссылка на решаемую задачу

Definition at line 160 of file TimesGen.h.


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