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.

This commit is contained in:
Michael Mueller
2024-07-23 16:20:22 +02:00
parent ad00e53c0b
commit 74befd9e3b

View File

@@ -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;
};
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<std::uint16_t>(static_cast<benchmark::phase>(_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