From c577f2c6a3b4ddb6ba87a882723c53a248afbeba Mon Sep 17 00:00:00 2001 From: telsoa01 Date: Fri, 31 Aug 2018 09:22:23 +0100 Subject: Release 18.08 --- src/armnn/test/InstrumentTests.cpp | 62 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/armnn/test/InstrumentTests.cpp (limited to 'src/armnn/test/InstrumentTests.cpp') diff --git a/src/armnn/test/InstrumentTests.cpp b/src/armnn/test/InstrumentTests.cpp new file mode 100644 index 0000000000..a219b39b0d --- /dev/null +++ b/src/armnn/test/InstrumentTests.cpp @@ -0,0 +1,62 @@ +// +// Copyright © 2017 Arm Ltd. All rights reserved. +// See LICENSE file in the project root for full license information. +// +#include + +#include "WallClockTimer.hpp" + +#include +#include + +using namespace armnn; + +BOOST_AUTO_TEST_SUITE(Instruments) + +BOOST_AUTO_TEST_CASE(WallClockTimerInMilliseconds) +{ + WallClockTimer wallClockTimer; + + BOOST_CHECK_EQUAL(wallClockTimer.GetName(), "WallClockTimer"); + + // start the timer + wallClockTimer.Start(); + + // wait for 10 milliseconds + std::this_thread::sleep_for(std::chrono::milliseconds(10)); + + // stop the timer + wallClockTimer.Stop(); + + BOOST_CHECK_EQUAL(wallClockTimer.GetMeasurements().front().m_Name, WallClockTimer::WALL_CLOCK_TIME); + + // check that WallClockTimer measurement should be >= 10 milliseconds + BOOST_CHECK_GE(wallClockTimer.GetMeasurements().front().m_Value, std::chrono::milliseconds(10).count()); +} + +BOOST_AUTO_TEST_CASE(WallClockTimerInNanoseconds) +{ + WallClockTimer wallClockTimer; + + BOOST_CHECK_EQUAL(wallClockTimer.GetName(), "WallClockTimer"); + + // start the timer + wallClockTimer.Start(); + + // wait for 500 nanoseconds - 0.0005 milliseconds + std::this_thread::sleep_for(std::chrono::nanoseconds(500)); + + // stop the timer + wallClockTimer.Stop(); + + BOOST_CHECK_EQUAL(wallClockTimer.GetMeasurements().front().m_Name, WallClockTimer::WALL_CLOCK_TIME); + + // delta is 0.0005 milliseconds + const auto delta = + std::chrono::duration_cast>(std::chrono::nanoseconds(500)); + + // check that WallClockTimer measurement should be >= 0.0005 milliseconds + BOOST_CHECK_GE(wallClockTimer.GetMeasurements().front().m_Value, delta.count()); +} + +BOOST_AUTO_TEST_SUITE_END() -- cgit v1.2.1