| 189 | } |
| 190 | |
| 191 | void JSONPrinter::print_measurements(const Profiler::MeasurementsMap &measurements) |
| 192 | { |
| 193 | print_separator(_first_test_entry); |
| 194 | *_stream << R"("measurements" : {)"; |
| 195 | |
| 196 | for (auto i_it = measurements.cbegin(), i_end = measurements.cend(); i_it != i_end;) |
| 197 | { |
| 198 | *_stream << R"(")" << i_it->first << R"(" : {)"; |
| 199 | |
| 200 | auto measurement_to_string = [](const Measurement &measurement) |
| 201 | { |
| 202 | if (measurement.raw_data().size() == 1) |
| 203 | { |
| 204 | return measurement.raw_data().front(); |
| 205 | } |
| 206 | else |
| 207 | { |
| 208 | std::stringstream str; |
| 209 | str << R"([")"; |
| 210 | str << join(measurement.raw_data().begin(), measurement.raw_data().end(), R"(",")"); |
| 211 | str << R"("])"; |
| 212 | return str.str(); |
| 213 | } |
| 214 | }; |
| 215 | *_stream << R"("raw" : [)" << join(i_it->second.begin(), i_it->second.end(), ",", measurement_to_string) |
| 216 | << "],"; |
| 217 | *_stream << R"("unit" : ")" << i_it->second.begin()->unit() << R"(")"; |
| 218 | *_stream << "}"; |
| 219 | |
| 220 | if (++i_it != i_end) |
| 221 | { |
| 222 | *_stream << ","; |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | *_stream << "}"; |
| 227 | } |
| 228 | } // namespace framework |
| 229 | } // namespace test |
| 230 | } // namespace arm_compute |