diff options
author | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-07 17:33:54 +0000 |
---|---|---|
committer | Anthony Barbier <Anthony.barbier@arm.com> | 2018-11-08 14:19:59 +0000 |
commit | 72f4ae5a53fe24226ff16ed9c339171887d74874 (patch) | |
tree | d43c9b20a3420e0785bec0c4439763411439b891 /tests/framework/instruments/WallClockTimer.cpp | |
parent | d2048ce58a88853cee6cdd67fe0d6f09c3e212b0 (diff) | |
download | ComputeLibrary-72f4ae5a53fe24226ff16ed9c339171887d74874.tar.gz |
COMPMID-1777: Add option to make instruments output timestamps instead of duration
Change-Id: Iafc1d6cd8003de64a3439ad807f4002036c73a73
Diffstat (limited to 'tests/framework/instruments/WallClockTimer.cpp')
-rw-r--r-- | tests/framework/instruments/WallClockTimer.cpp | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/tests/framework/instruments/WallClockTimer.cpp b/tests/framework/instruments/WallClockTimer.cpp index 6c69360236..f309efca1c 100644 --- a/tests/framework/instruments/WallClockTimer.cpp +++ b/tests/framework/instruments/WallClockTimer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -32,26 +32,52 @@ namespace test { namespace framework { -std::string WallClockTimer::id() const +template <bool output_timestamps> +std::string WallClock<output_timestamps>::id() const { - return "Wall clock"; + if(output_timestamps) + { + return "Wall clock timestamps"; + } + else + { + return "Wall clock"; + } } -void WallClockTimer::start() +template <bool output_timestamps> +void WallClock<output_timestamps>::start() { _start = std::chrono::high_resolution_clock::now(); } -void WallClockTimer::stop() +template <bool output_timestamps> +void WallClock<output_timestamps>::stop() { _stop = std::chrono::high_resolution_clock::now(); } -Instrument::MeasurementsMap WallClockTimer::measurements() const +template <bool output_timestamps> +Instrument::MeasurementsMap WallClock<output_timestamps>::measurements() const { - const auto delta = std::chrono::duration_cast<std::chrono::microseconds>(_stop - _start); - return MeasurementsMap{ { "Wall clock time", Measurement(delta.count() / _scale_factor, _unit) } }; + MeasurementsMap measurements; + if(output_timestamps) + { + // _start / _stop are in ns, so divide by an extra 1000: + measurements.emplace("[start]Wall clock time", Measurement(_start.time_since_epoch().count() / static_cast<uint64_t>(1000 * _scale_factor), _unit)); + measurements.emplace("[end]Wall clock time", Measurement(_stop.time_since_epoch().count() / static_cast<uint64_t>(1000 * _scale_factor), _unit)); + } + else + { + const auto delta = std::chrono::duration_cast<std::chrono::microseconds>(_stop - _start); + measurements.emplace("Wall clock time", Measurement(delta.count() / _scale_factor, _unit)); + } + return measurements; } + +template class WallClock<true>; +template class WallClock<false>; + } // namespace framework } // namespace test } // namespace arm_compute |