From f6e534a82d167403c5980e3ea3b67135ff9be78b Mon Sep 17 00:00:00 2001 From: FinnWilliamsArm Date: Mon, 16 Sep 2019 15:45:42 +0100 Subject: IVGCVSW-3411 Add the Counter Values array and accessor methods Signed-off-by: FinnWilliamsArm Change-Id: I4fa2428a83b93cbe58b821344206e2f7ce9e37e7 --- src/profiling/test/ProfilingTests.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/profiling/test') diff --git a/src/profiling/test/ProfilingTests.cpp b/src/profiling/test/ProfilingTests.cpp index 48723dbc34..b90d469424 100644 --- a/src/profiling/test/ProfilingTests.cpp +++ b/src/profiling/test/ProfilingTests.cpp @@ -702,6 +702,38 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceCounterDirectory) BOOST_CHECK(counterDirectory1.GetCounterCount() != 0); } +BOOST_AUTO_TEST_CASE(CheckProfilingServiceCounterValues) +{ + armnn::Runtime::CreationOptions::ExternalProfilingOptions options; + options.m_EnableProfiling = true; + ProfilingService profilingService(options); + + ProfilingService* profilingServicePtr = &profilingService; + std::vector writers; + + for(int i = 0; i < 100 ; ++i) + { + // Increment and decrement counter 0 + writers.push_back(std::thread(&ProfilingService::IncrementCounterValue, profilingServicePtr, 0)); + writers.push_back(std::thread(&ProfilingService::DecrementCounterValue, profilingServicePtr, 0)); + // Add 10 to counter 0 and subtract 5 from counter 0 + writers.push_back(std::thread(&ProfilingService::AddCounterValue, profilingServicePtr, 0, 10)); + writers.push_back(std::thread(&ProfilingService::SubtractCounterValue, profilingServicePtr, 0, 5)); + } + + std::for_each(writers.begin(), writers.end(), mem_fn(&std::thread::join)); + + uint32_t counterValue; + profilingService.GetCounterValue(0, counterValue); + BOOST_CHECK(counterValue == 500); + + profilingService.SetCounterValue(0, 0); + profilingService.GetCounterValue(0, counterValue); + BOOST_CHECK(counterValue == 0); + + BOOST_CHECK_THROW(profilingService.SetCounterValue(profilingService.GetCounterCount(), 1), armnn::Exception); +} + BOOST_AUTO_TEST_CASE(CheckProfilingObjectUids) { uint16_t uid = 0; -- cgit v1.2.1