aboutsummaryrefslogtreecommitdiff
path: root/src/csv_reporter.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/csv_reporter.cc')
-rw-r--r--src/csv_reporter.cc27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/csv_reporter.cc b/src/csv_reporter.cc
index af2c18f..7b56da1 100644
--- a/src/csv_reporter.cc
+++ b/src/csv_reporter.cc
@@ -12,9 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "benchmark/benchmark.h"
-#include "complexity.h"
-
#include <algorithm>
#include <cstdint>
#include <iostream>
@@ -22,7 +19,9 @@
#include <tuple>
#include <vector>
+#include "benchmark/benchmark.h"
#include "check.h"
+#include "complexity.h"
#include "string_util.h"
#include "timers.h"
@@ -37,23 +36,29 @@ std::vector<std::string> elements = {
"error_occurred", "error_message"};
} // namespace
-std::string CsvEscape(const std::string & s) {
+std::string CsvEscape(const std::string& s) {
std::string tmp;
tmp.reserve(s.size() + 2);
for (char c : s) {
switch (c) {
- case '"' : tmp += "\"\""; break;
- default : tmp += c; break;
+ case '"':
+ tmp += "\"\"";
+ break;
+ default:
+ tmp += c;
+ break;
}
}
return '"' + tmp + '"';
}
+BENCHMARK_EXPORT
bool CSVReporter::ReportContext(const Context& context) {
PrintBasicContext(&GetErrorStream(), context);
return true;
}
+BENCHMARK_EXPORT
void CSVReporter::ReportRuns(const std::vector<Run>& reports) {
std::ostream& Out = GetOutputStream();
@@ -85,7 +90,8 @@ void CSVReporter::ReportRuns(const std::vector<Run>& reports) {
for (const auto& cnt : run.counters) {
if (cnt.first == "bytes_per_second" || cnt.first == "items_per_second")
continue;
- CHECK(user_counter_names_.find(cnt.first) != user_counter_names_.end())
+ BM_CHECK(user_counter_names_.find(cnt.first) !=
+ user_counter_names_.end())
<< "All counters must be present in each run. "
<< "Counter named \"" << cnt.first
<< "\" was not in a run after being added to the header";
@@ -99,13 +105,14 @@ void CSVReporter::ReportRuns(const std::vector<Run>& reports) {
}
}
+BENCHMARK_EXPORT
void CSVReporter::PrintRunData(const Run& run) {
std::ostream& Out = GetOutputStream();
Out << CsvEscape(run.benchmark_name()) << ",";
- if (run.error_occurred) {
+ if (run.skipped) {
Out << std::string(elements.size() - 3, ',');
- Out << "true,";
- Out << CsvEscape(run.error_message) << "\n";
+ Out << std::boolalpha << (internal::SkippedWithError == run.skipped) << ",";
+ Out << CsvEscape(run.skip_message) << "\n";
return;
}