summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2019-10-10 18:48:17 +0300
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2019-10-10 19:54:51 +0300
commit63116154fe7e1f49d7751c002e2abe5422fd22ee (patch)
treeb7cde7304388b083e93658e332cede450ca43686
parent629c0e1142a382ada101e93e7c58bd2b1bce37bc (diff)
downloadqtlocation-mapboxgl-63116154fe7e1f49d7751c002e2abe5422fd22ee.tar.gz
[render-test] Only write metrics if they are available
Otherwise the file will have an empty tag.
-rw-r--r--render-test/parser.cpp38
1 files 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();