From 74befd9e3b4404d56687525e0a5cfe2b2ec86280 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 23 Jul 2024 16:20:22 +0200 Subject: [PATCH] Use tasks to start and stop measurements to ensure that only the TSC used to detemine the starting point is the same as the one used for detemining the end timepoint. --- .../blinktree_benchmark/benchmark.h | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/application/blinktree_benchmark/benchmark.h b/src/application/blinktree_benchmark/benchmark.h index ae0b789..13a4d67 100644 --- a/src/application/blinktree_benchmark/benchmark.h +++ b/src/application/blinktree_benchmark/benchmark.h @@ -99,5 +99,39 @@ private: * @return Name of the file to write profiling results to. */ [[nodiscard]] std::string profile_file_name() const; + + friend class StartMeasurementTask; + friend class StopMeasurementTask; }; -} // namespace application::blinktree_benchmark \ No newline at end of file + +class StartMeasurementTask : public mx::tasking::TaskInterface +{ + private: + Benchmark &_benchmark; + + public: + constexpr StartMeasurementTask(Benchmark& benchmark) : _benchmark(benchmark) {} + ~StartMeasurementTask() override = default; + + mx::tasking::TaskResult execute(const std::uint16_t, const std::uint16_t) override + { + _benchmark._chronometer.start(static_cast(static_cast(_benchmark._workload)), _benchmark._current_iteration + 1, _benchmark._cores.current()); + return mx::tasking::TaskResult::make_remove(); + } +}; +class StopMeasurementTask : public mx::tasking::TaskInterface +{ + private: + Benchmark &_benchmark; + + public: + constexpr StopMeasurementTask(Benchmark &benchmark) : _benchmark(benchmark) {} + ~StopMeasurementTask() override = default; + + mx::tasking::TaskResult execute(const std::uint16_t core_id, const std::uint16_t channel_id) override + { + _benchmark.requests_finished(); + return mx::tasking::TaskResult::make_remove(); + } +}; +} // namespace application::blinktree_benchmark