From 63116154fe7e1f49d7751c002e2abe5422fd22ee Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Thu, 10 Oct 2019 18:48:17 +0300 Subject: [render-test] Only write metrics if they are available Otherwise the file will have an empty tag. --- render-test/parser.cpp | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/render-test/parser.cpp b/render-test/parser.cpp index 3da7e6ea01..34cccad2a2 100644 --- a/render-test/parser.cpp +++ b/render-test/parser.cpp @@ -275,32 +275,34 @@ std::string serializeMetrics(const TestMetrics& metrics) { writer.StartObject(); // Start fileSize section. - writer.Key("fileSize"); - writer.StartArray(); - for (const auto& fileSizeProbe : metrics.fileSize) { - assert(!fileSizeProbe.first.empty()); + if (!metrics.fileSize.empty()) { + writer.Key("fileSize"); writer.StartArray(); - writer.String(fileSizeProbe.first.c_str()); - writer.String(fileSizeProbe.second.path); - writer.Uint64(fileSizeProbe.second.size); + for (const auto& fileSizeProbe : metrics.fileSize) { + assert(!fileSizeProbe.first.empty()); + writer.StartArray(); + writer.String(fileSizeProbe.first.c_str()); + writer.String(fileSizeProbe.second.path); + writer.Uint64(fileSizeProbe.second.size); + writer.EndArray(); + } writer.EndArray(); } - // End fileSize section. - writer.EndArray(); // Start memory section. - writer.Key("memory"); - writer.StartArray(); - for (const auto& memoryProbe : metrics.memory) { - assert(!memoryProbe.first.empty()); + if (!metrics.memory.empty()) { + writer.Key("memory"); writer.StartArray(); - writer.String(memoryProbe.first.c_str()); - writer.Uint64(memoryProbe.second.peak); - writer.Uint64(memoryProbe.second.allocations); + for (const auto& memoryProbe : metrics.memory) { + assert(!memoryProbe.first.empty()); + writer.StartArray(); + writer.String(memoryProbe.first.c_str()); + writer.Uint64(memoryProbe.second.peak); + writer.Uint64(memoryProbe.second.allocations); + writer.EndArray(); + } writer.EndArray(); } - // End memory section. - writer.EndArray(); writer.EndObject(); -- cgit v1.2.1