diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-08-25 19:55:21 +0300 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-08-27 12:34:09 +0300 |
commit | d0a84cb7d9866d4d46141ef2735697de3302d50b (patch) | |
tree | f31d3892951c803ca6a15d3152fec558c6b4a1d6 | |
parent | e787f5f43ae0136003606ad0276d68def3c76437 (diff) | |
download | qtlocation-mapboxgl-d0a84cb7d9866d4d46141ef2735697de3302d50b.tar.gz |
[test runner] Introduce probe_memory_.. API for render tests
-rw-r--r-- | render-test/metadata.hpp | 14 | ||||
-rw-r--r-- | render-test/runner.cpp | 28 |
2 files changed, 40 insertions, 2 deletions
diff --git a/render-test/metadata.hpp b/render-test/metadata.hpp index 98e208fe54..308c9074f0 100644 --- a/render-test/metadata.hpp +++ b/render-test/metadata.hpp @@ -7,6 +7,8 @@ #include "filesystem.hpp" +#include <map> + struct TestStatistics { TestStatistics() = default; @@ -27,6 +29,16 @@ struct TestPaths { } }; +struct MemoryProbe { + MemoryProbe() = default; + MemoryProbe(size_t size_, size_t allocations_) + : size(size_) + , allocations(allocations_) {} + + size_t size; + size_t allocations; +}; + struct TestMetadata { TestMetadata() = default; @@ -59,4 +71,6 @@ struct TestMetadata { std::string errorMessage; double difference = 0.0; + + std::map<std::string, MemoryProbe> memoryProbes; };
\ No newline at end of file diff --git a/render-test/runner.cpp b/render-test/runner.cpp index 192978ffa5..5424eaa447 100644 --- a/render-test/runner.cpp +++ b/render-test/runner.cpp @@ -18,6 +18,7 @@ #include <mapbox/pixelmatch.hpp> +#include "allocation_index.hpp" #include "metadata.hpp" #include "parser.hpp" #include "runner.hpp" @@ -25,7 +26,7 @@ #include <algorithm> #include <cassert> #include <regex> - +#include <utility> // static const std::string& TestRunner::getBasePath() { @@ -155,6 +156,9 @@ bool TestRunner::runOperations(const std::string& key, TestMetadata& metadata) { static const std::string removeSourceOp("removeSource"); static const std::string setPaintPropertyOp("setPaintProperty"); static const std::string setLayoutPropertyOp("setLayoutProperty"); + static const std::string memoryProbeOp("probeMemory"); + static const std::string memoryProbeStartOp("probeMemoryStart"); + static const std::string memoryProbeEndOp("probeMemoryEnd"); // wait if (operationArray[0].GetString() == waitOp) { @@ -392,7 +396,25 @@ bool TestRunner::runOperations(const std::string& key, TestMetadata& metadata) { const mbgl::JSValue* propertyValue = &operationArray[3]; layer->setLayoutProperty(propertyName, propertyValue); } - + // probeMemoryStart + } else if (operationArray[0].GetString() == memoryProbeStartOp) { + assert(!AllocationIndex::isActive()); + AllocationIndex::setActive(true); + // probeMemory + } else if (operationArray[0].GetString() == memoryProbeOp) { + assert(AllocationIndex::isActive()); + assert(operationArray.Size() >= 2u); + assert(operationArray[1].IsString()); + std::string mark = std::string(operationArray[1].GetString(), operationArray[1].GetStringLength()); + + metadata.memoryProbes.emplace(std::piecewise_construct, + std::forward_as_tuple(std::move(mark)), + std::forward_as_tuple(AllocationIndex::getAllocatedSize(), AllocationIndex::getAllocationsCount())); + // probeMemoryEnd + } else if (operationArray[0].GetString() == memoryProbeEndOp) { + assert(AllocationIndex::isActive()); + AllocationIndex::setActive(false); + AllocationIndex::reset(); } else { metadata.errorMessage = std::string("Unsupported operation: ") + operationArray[0].GetString(); return false; @@ -414,6 +436,8 @@ TestRunner::Impl::Impl(const TestMetadata& metadata) mbgl::ResourceOptions().withCacheOnlyRequestsSupport(false)) {} bool TestRunner::run(TestMetadata& metadata) { + AllocationIndex::setActive(false); + AllocationIndex::reset(); std::string key = mbgl::util::toString(uint32_t(metadata.mapMode)) + "/" + mbgl::util::toString(metadata.pixelRatio) + "/" + mbgl::util::toString(uint32_t(metadata.crossSourceCollisions)); |