15 #include "benchmark/benchmark.h"
34 std::vector<std::string> elements = {
35 "name",
"iterations",
"real_time",
"cpu_time",
36 "time_unit",
"bytes_per_second",
"items_per_second",
"label",
37 "error_occurred",
"error_message"};
42 tmp.reserve(s.size() + 2);
45 case '"' :
tmp +=
"\"\"";
break;
49 return '"' +
tmp +
'"';
62 for (
const auto&
run : reports) {
63 for (
const auto& cnt :
run.counters) {
64 if (cnt.first ==
"bytes_per_second" || cnt.first ==
"items_per_second")
71 for (
auto B = elements.begin(); B != elements.end();) {
73 if (B != elements.end()) Out <<
",";
77 Out <<
",\"" << *B++ <<
"\"";
84 for (
const auto&
run : reports) {
85 for (
const auto& cnt :
run.counters) {
86 if (cnt.first ==
"bytes_per_second" || cnt.first ==
"items_per_second")
90 <<
"All counters must be present in each run. "
91 <<
"Counter named \"" << cnt.first
92 <<
"\" was not in a run after being added to the header";
98 for (
const auto&
run : reports) {
106 if (
run.error_occurred) {
114 if (!
run.report_big_o && !
run.report_rms) {
115 Out <<
run.iterations;
119 Out <<
run.GetAdjustedRealTime() <<
",";
120 Out <<
run.GetAdjustedCPUTime() <<
",";
123 if (
run.report_big_o) {
125 }
else if (!
run.report_rms) {
130 if (
run.counters.find(
"bytes_per_second") !=
run.counters.end()) {
131 Out <<
run.counters.at(
"bytes_per_second");
134 if (
run.counters.find(
"items_per_second") !=
run.counters.end()) {
135 Out <<
run.counters.at(
"items_per_second");
138 if (!
run.report_label.empty()) {
145 auto it =
run.counters.find(ucn);
146 if (
it ==
run.counters.end()) {
149 Out <<
"," <<
it->second;