| 68 | ///////////////////////////////////////////////////////////////////////////////////////////////// |
| 69 | |
| 70 | PerformanceReport::PerformanceReport( |
| 71 | Options const &options, |
| 72 | std::vector<std::string> const &argument_names, |
| 73 | library::OperationKind const &op_kind |
| 74 | ): |
| 75 | options_(options), argument_names_(argument_names), problem_index_(0), good_(true), op_kind_(op_kind) { |
| 76 | |
| 77 | // Strip '.csv' if present |
| 78 | std::string base_path = options_.report.output_path; |
| 79 | base_path = base_path.substr(0, base_path.rfind(".csv")); |
| 80 | op_file_name_ = base_path + "." + to_string(op_kind_) + ".csv"; |
| 81 | |
| 82 | base_path = options_.report.junit_output_path; |
| 83 | base_path = base_path.substr(0, base_path.rfind(".xml")); |
| 84 | base_path = base_path.substr(0, base_path.rfind(".junit")); |
| 85 | op_junit_file_name_ = base_path + "." + to_string(op_kind_) + ".junit.xml"; |
| 86 | |
| 87 | // |
| 88 | // Open output file for operation of PerformanceReport::op_kind |
| 89 | // |
| 90 | if (!options_.report.output_path.empty()) { |
| 91 | |
| 92 | bool print_header = true; |
| 93 | |
| 94 | if (options_.report.append) { |
| 95 | |
| 96 | std::ifstream test_output_file(op_file_name_); |
| 97 | |
| 98 | if (test_output_file.is_open()) { |
| 99 | print_header = false; |
| 100 | test_output_file.close(); |
| 101 | } |
| 102 | |
| 103 | output_file_.open(op_file_name_, std::ios::app); |
| 104 | } |
| 105 | else { |
| 106 | output_file_.open(op_file_name_); |
| 107 | } |
| 108 | |
| 109 | if (!output_file_.good()) { |
| 110 | |
| 111 | std::cerr << "Could not open output file at path '" |
| 112 | << options_.report.output_path << "'" << std::endl; |
| 113 | |
| 114 | good_ = false; |
| 115 | } |
| 116 | |
| 117 | if (print_header) { |
| 118 | print_csv_header_(output_file_) << std::endl; |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | if (!options_.report.junit_output_path.empty()) { |
| 123 | |
| 124 | junit_output_file_.open(op_junit_file_name_); |
| 125 | |
| 126 | if (!junit_output_file_.good()) { |
| 127 | |