13
13
14
14
#include < nlohmann/json.hpp>
15
15
16
- struct EnvironmentInfo {
16
+ struct Environment {
17
17
std::string Description;
18
- std::string Path;
18
+ std::string InfoPath;
19
+ std::string BenchmarkingResultsPath;
19
20
20
- friend void to_json (nlohmann::json& j, const EnvironmentInfo & e) {
21
+ friend void to_json (nlohmann::json& j, const Environment & e) {
21
22
j = nlohmann::json{
22
23
{" Description" , e.Description },
23
- {" Path" , e.Path }
24
+ {" InfoPath" , e.InfoPath },
25
+ {" BenchmarkingResultsPath" , e.BenchmarkingResultsPath },
24
26
};
25
27
}
26
28
27
- friend void from_json (const nlohmann::json& j, EnvironmentInfo & e) {
29
+ friend void from_json (const nlohmann::json& j, Environment & e) {
28
30
j.at (" Description" ).get_to (e.Description );
29
- j.at (" Path" ).get_to (e.Path );
31
+ j.at (" InfoPath" ).get_to (e.InfoPath );
32
+ j.at (" BenchmarkingResultsPath" ).get_to (e.BenchmarkingResultsPath );
30
33
}
31
34
};
32
35
33
- struct MetricInfo {
36
+ struct EnvironmentInfo {
37
+ std::string OS;
38
+ std::string KernelVersion;
39
+ std::string Architecture;
40
+ std::string Compiler;
41
+
42
+ friend void to_json (nlohmann::json& j, const EnvironmentInfo& e) {
43
+ j = nlohmann::json{
44
+ {" OS" , e.OS },
45
+ {" KernelVersion" , e.KernelVersion },
46
+ {" Architecture" , e.Architecture },
47
+ {" Compiler" , e.Compiler },
48
+ };
49
+ }
50
+
51
+ friend void from_json (const nlohmann::json& j, EnvironmentInfo& e) {
52
+ j.at (" OS" ).get_to (e.OS );
53
+ j.at (" KernelVersion" ).get_to (e.KernelVersion );
54
+ j.at (" Architecture" ).get_to (e.Architecture );
55
+ j.at (" Compiler" ).get_to (e.Compiler );
56
+ }
57
+ };
58
+
59
+ struct Metric {
34
60
std::string Name;
35
61
std::string TargetBenchmarkName;
36
62
std::string BaselineBenchmarkName;
37
63
38
- friend void to_json (nlohmann::json& j, const MetricInfo & m) {
64
+ friend void to_json (nlohmann::json& j, const Metric & m) {
39
65
j = nlohmann::json{
40
66
{" Name" , m.Name },
41
67
{" TargetBenchmarkName" , m.TargetBenchmarkName },
42
- {" BaselineBenchmarkName" , m.BaselineBenchmarkName }
68
+ {" BaselineBenchmarkName" , m.BaselineBenchmarkName },
43
69
};
44
70
}
45
71
46
- friend void from_json (const nlohmann::json& j, MetricInfo & m) {
72
+ friend void from_json (const nlohmann::json& j, Metric & m) {
47
73
j.at (" Name" ).get_to (m.Name );
48
74
j.at (" TargetBenchmarkName" ).get_to (m.TargetBenchmarkName );
49
75
j.at (" BaselineBenchmarkName" ).get_to (m.BaselineBenchmarkName );
@@ -54,16 +80,16 @@ struct ReportConfig {
54
80
std::string TargetName;
55
81
double YellowIndicatorThreshold;
56
82
std::string OutputPath;
57
- std::vector<EnvironmentInfo > Environments;
58
- std::vector<MetricInfo > Metrics;
83
+ std::vector<Environment > Environments;
84
+ std::vector<Metric > Metrics;
59
85
60
86
friend void to_json (nlohmann::json& j, const ReportConfig& rc) {
61
87
j = nlohmann::json{
62
88
{" TargetName" , rc.TargetName },
63
89
{" YellowIndicatorThreshold" , rc.YellowIndicatorThreshold },
64
90
{" OutputPath" , rc.OutputPath },
65
91
{" Environments" , rc.Environments },
66
- {" Metrics" , rc.Metrics }
92
+ {" Metrics" , rc.Metrics },
67
93
};
68
94
}
69
95
@@ -78,7 +104,16 @@ struct ReportConfig {
78
104
79
105
const std::string_view MedianSuffix = " _median" ;
80
106
81
- std::unordered_map<std::string, double > Parse (const std::filesystem::path& file) {
107
+ EnvironmentInfo ParseEnvironmentInfo (const std::filesystem::path& file) {
108
+ nlohmann::json obj;
109
+ std::ifstream in;
110
+ in.exceptions (std::ios_base::failbit | std::ios_base::badbit);
111
+ in.open (file, std::ios_base::in | std::ios_base::binary);
112
+ in >> obj;
113
+ return obj.get <EnvironmentInfo>();
114
+ }
115
+
116
+ std::unordered_map<std::string, double > ParseBenchmarkingResults (const std::filesystem::path& file) {
82
117
nlohmann::json obj;
83
118
{
84
119
std::ifstream in;
@@ -111,7 +146,7 @@ void GenerateReport(const std::filesystem::path& config_path) {
111
146
std::vector<std::unordered_map<std::string, double >> benchmarks;
112
147
benchmarks.reserve (config.Environments .size ());
113
148
for (auto & environment : config.Environments ) {
114
- benchmarks.push_back (Parse (environment.Path ));
149
+ benchmarks.push_back (ParseBenchmarkingResults (environment.BenchmarkingResultsPath ));
115
150
}
116
151
std::ofstream out;
117
152
out.exceptions (std::ios_base::failbit | std::ios_base::badbit);
@@ -155,6 +190,13 @@ void GenerateReport(const std::filesystem::path& config_path) {
155
190
}
156
191
out << " \n " ;
157
192
}
193
+ out << " \n ## Environments\n\n " ;
194
+ out << " | | Operating System | Kernel Version | Architecture | Compiler |\n " ;
195
+ out << " | - | - | - | - | - |\n " ;
196
+ for (auto & environment : config.Environments ) {
197
+ EnvironmentInfo env_info = ParseEnvironmentInfo (environment.InfoPath );
198
+ out << " | **" << environment.Description << " ** | " << env_info.OS << " | " << env_info.KernelVersion << " | " << env_info.Architecture << " | " << env_info.Compiler << " |\n " ;
199
+ }
158
200
}
159
201
160
202
int main (int argc, char ** argv) {
0 commit comments