AYON Cpp Api  0.1.0
Loading...
Searching...
No Matches
perfPrinter.h
Go to the documentation of this file.
1#include <chrono>
2#include <iostream>
3#include <string>
4#include <vector>
5
6struct perfStats {
7 std::chrono::time_point<std::chrono::high_resolution_clock> startTime;
8 std::chrono::time_point<std::chrono::high_resolution_clock> endTime;
9 std::string StatName;
10 std::string HeaderText;
11 std::string FoderText;
12 std::string Note;
13 std::vector<std::string> extraInfo;
14 bool Stop = false;
15};
16
18 public:
20
21 perfPrinter(const std::string &Name) {
23 currentRunStats.startTime = std::chrono::high_resolution_clock::now();
24 }
26 this->printStats();
27 };
28
29 void
31 std::cout << currentRunStats.StatName << "\n"
33 << currentRunStats.Note << "\n";
34
35 // Print Time Info
36 long long castedStartTime
37 = std::chrono::time_point_cast<std::chrono::microseconds>(currentRunStats.startTime)
38 .time_since_epoch()
39 .count();
40
41 long long castEndTime
42 = std::chrono::time_point_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now())
43 .time_since_epoch()
44 .count();
45 std::cout << "Execution Time: " << castedStartTime - castEndTime << "\n";
46
47 std::cout << "ThreadId: " << std::hash<std::thread::id>{}(std::this_thread::get_id()) << "\n";
48
49 // Print Extra Info
50 for (const std::string &infoEntry: currentRunStats.extraInfo) {
51 std::cout << infoEntry << "\n";
52 }
53 std::cout << currentRunStats.FoderText << std::endl;
54 };
55};
Definition: perfPrinter.h:17
~perfPrinter()
Definition: perfPrinter.h:25
void printStats()
Definition: perfPrinter.h:30
perfPrinter(const std::string &Name)
Definition: perfPrinter.h:21
perfStats currentRunStats
Definition: perfPrinter.h:19
Definition: perfPrinter.h:6
std::string StatName
Definition: perfPrinter.h:9
bool Stop
Definition: perfPrinter.h:14
std::string FoderText
Definition: perfPrinter.h:11
std::vector< std::string > extraInfo
Definition: perfPrinter.h:13
std::chrono::time_point< std::chrono::high_resolution_clock > startTime
Definition: perfPrinter.h:7
std::string Note
Definition: perfPrinter.h:12
std::chrono::time_point< std::chrono::high_resolution_clock > endTime
Definition: perfPrinter.h:8
std::string HeaderText
Definition: perfPrinter.h:10