mirror of
https://github.com/mmueller41/mxtasking.git
synced 2026-01-21 12:42:57 +01:00
Removed std::chrono reference and dump to serial console.
This commit is contained in:
@@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
using namespace mx::tasking::profiling;
|
using namespace mx::tasking::profiling;
|
||||||
|
|
||||||
ProfilingTask::ProfilingTask(mx::util::maybe_atomic<bool> &is_running, mx::tasking::Channel &channel)
|
ProfilingTask::ProfilingTask(mx::util::maybe_atomic<bool> &is_running, mx::tasking::Channel &channel, Timer::Connection &timer)
|
||||||
: _is_running(is_running), _channel(channel), _timer (*new (memory::GlobalHeap::heap()) Timer::Connection(*system::Environment::env()))
|
: _is_running(is_running), _channel(channel), _timer (timer)
|
||||||
{
|
{
|
||||||
_idle_ranges.reserve(1 << 16);
|
_idle_ranges.reserve(1 << 16);
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ void Profiler::profile(const std::string &profiling_output_file)
|
|||||||
void Profiler::profile(util::maybe_atomic<bool> &is_running, Channel &channel)
|
void Profiler::profile(util::maybe_atomic<bool> &is_running, Channel &channel)
|
||||||
{
|
{
|
||||||
auto *task =
|
auto *task =
|
||||||
new (memory::GlobalHeap::allocate_cache_line_aligned(sizeof(ProfilingTask))) ProfilingTask(is_running, channel);
|
new (memory::GlobalHeap::allocate_cache_line_aligned(sizeof(ProfilingTask))) ProfilingTask(is_running, channel, _timer);
|
||||||
task->annotate(channel.id());
|
task->annotate(channel.id());
|
||||||
task->annotate(mx::tasking::priority::low);
|
task->annotate(mx::tasking::priority::low);
|
||||||
this->_tasks.push_back(task);
|
this->_tasks.push_back(task);
|
||||||
@@ -68,7 +68,7 @@ void Profiler::profile(util::maybe_atomic<bool> &is_running, Channel &channel)
|
|||||||
|
|
||||||
void Profiler::stop()
|
void Profiler::stop()
|
||||||
{
|
{
|
||||||
const auto end = std::chrono::steady_clock::now();
|
const auto end = std::chrono::time_point<std::chrono::steady_clock>(std::chrono::microseconds(_timer.elapsed_ms()));
|
||||||
const auto end_relative_nanoseconds =
|
const auto end_relative_nanoseconds =
|
||||||
std::chrono::duration_cast<std::chrono::nanoseconds>(end - this->_start).count();
|
std::chrono::duration_cast<std::chrono::nanoseconds>(end - this->_start).count();
|
||||||
if (this->_profiling_output_file.has_value())
|
if (this->_profiling_output_file.has_value())
|
||||||
@@ -99,8 +99,8 @@ void Profiler::stop()
|
|||||||
end_output["end"] = end_relative_nanoseconds;
|
end_output["end"] = end_relative_nanoseconds;
|
||||||
output.push_back(std::move(end_output));
|
output.push_back(std::move(end_output));
|
||||||
|
|
||||||
std::ofstream out_file{this->_profiling_output_file.value()};
|
//std::ofstream out_file{this->_profiling_output_file.value()};
|
||||||
out_file << output.dump() << std::endl;
|
Genode::log(output.dump()); // dump to serial console for the moment
|
||||||
}
|
}
|
||||||
|
|
||||||
this->_profiling_output_file = std::nullopt;
|
this->_profiling_output_file = std::nullopt;
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ private:
|
|||||||
class ProfilingTask final : public TaskInterface
|
class ProfilingTask final : public TaskInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ProfilingTask(util::maybe_atomic<bool> &is_running, Channel &channel);
|
ProfilingTask(util::maybe_atomic<bool> &is_running, Channel &channel, Timer::Connection &timer);
|
||||||
~ProfilingTask() override = default;
|
~ProfilingTask() override = default;
|
||||||
|
|
||||||
TaskResult execute(std::uint16_t core_id, std::uint16_t channel_id) override;
|
TaskResult execute(std::uint16_t core_id, std::uint16_t channel_id) override;
|
||||||
@@ -90,7 +90,7 @@ private:
|
|||||||
class Profiler
|
class Profiler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Profiler() noexcept = default;
|
Profiler() : _timer(*new (memory::GlobalHeap::heap()) Timer::Connection(*system::Environment::env())) {}
|
||||||
~Profiler();
|
~Profiler();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -121,6 +121,8 @@ private:
|
|||||||
|
|
||||||
// List of all idle/profile tasks.
|
// List of all idle/profile tasks.
|
||||||
std::vector<ProfilingTask *> _tasks;
|
std::vector<ProfilingTask *> _tasks;
|
||||||
|
|
||||||
|
Timer::Connection &_timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mx::tasking::profiling
|
} // namespace mx::tasking::profiling
|
||||||
Reference in New Issue
Block a user