1313
1414#include < nlohmann/json.hpp>
1515
16- struct EnvironmentInfo {
16+ struct Environment {
1717 std::string Description;
18- std::string Path;
18+ std::string InfoPath;
19+ std::string BenchmarkingResultsPath;
1920
20- friend void to_json (nlohmann::json& j, const EnvironmentInfo & e) {
21+ friend void to_json (nlohmann::json& j, const Environment & e) {
2122 j = nlohmann::json{
2223 {" Description" , e.Description },
23- {" Path" , e.Path }
24+ {" InfoPath" , e.InfoPath },
25+ {" BenchmarkingResultsPath" , e.BenchmarkingResultsPath },
2426 };
2527 }
2628
27- friend void from_json (const nlohmann::json& j, EnvironmentInfo & e) {
29+ friend void from_json (const nlohmann::json& j, Environment & e) {
2830 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 );
3033 }
3134};
3235
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 {
3460 std::string Name;
3561 std::string TargetBenchmarkName;
3662 std::string BaselineBenchmarkName;
3763
38- friend void to_json (nlohmann::json& j, const MetricInfo & m) {
64+ friend void to_json (nlohmann::json& j, const Metric & m) {
3965 j = nlohmann::json{
4066 {" Name" , m.Name },
4167 {" TargetBenchmarkName" , m.TargetBenchmarkName },
42- {" BaselineBenchmarkName" , m.BaselineBenchmarkName }
68+ {" BaselineBenchmarkName" , m.BaselineBenchmarkName },
4369 };
4470 }
4571
46- friend void from_json (const nlohmann::json& j, MetricInfo & m) {
72+ friend void from_json (const nlohmann::json& j, Metric & m) {
4773 j.at (" Name" ).get_to (m.Name );
4874 j.at (" TargetBenchmarkName" ).get_to (m.TargetBenchmarkName );
4975 j.at (" BaselineBenchmarkName" ).get_to (m.BaselineBenchmarkName );
@@ -54,16 +80,16 @@ struct ReportConfig {
5480 std::string TargetName;
5581 double YellowIndicatorThreshold;
5682 std::string OutputPath;
57- std::vector<EnvironmentInfo > Environments;
58- std::vector<MetricInfo > Metrics;
83+ std::vector<Environment > Environments;
84+ std::vector<Metric > Metrics;
5985
6086 friend void to_json (nlohmann::json& j, const ReportConfig& rc) {
6187 j = nlohmann::json{
6288 {" TargetName" , rc.TargetName },
6389 {" YellowIndicatorThreshold" , rc.YellowIndicatorThreshold },
6490 {" OutputPath" , rc.OutputPath },
6591 {" Environments" , rc.Environments },
66- {" Metrics" , rc.Metrics }
92+ {" Metrics" , rc.Metrics },
6793 };
6894 }
6995
@@ -78,7 +104,16 @@ struct ReportConfig {
78104
79105const std::string_view MedianSuffix = " _median" ;
80106
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) {
82117 nlohmann::json obj;
83118 {
84119 std::ifstream in;
@@ -111,7 +146,7 @@ void GenerateReport(const std::filesystem::path& config_path) {
111146 std::vector<std::unordered_map<std::string, double >> benchmarks;
112147 benchmarks.reserve (config.Environments .size ());
113148 for (auto & environment : config.Environments ) {
114- benchmarks.push_back (Parse (environment.Path ));
149+ benchmarks.push_back (ParseBenchmarkingResults (environment.BenchmarkingResultsPath ));
115150 }
116151 std::ofstream out;
117152 out.exceptions (std::ios_base::failbit | std::ios_base::badbit);
@@ -155,6 +190,13 @@ void GenerateReport(const std::filesystem::path& config_path) {
155190 }
156191 out << " \n " ;
157192 }
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+ }
158200}
159201
160202int main (int argc, char ** argv) {
0 commit comments