mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:38:10 +00:00
SystemMonitor: Don't reopen process statistics file on every update
This file can just remain open; we seek to its start anyways. This previously accounted for over 5% of SystemMonitor runtime.
This commit is contained in:
parent
26d8ac844c
commit
7d53767ce8
2 changed files with 20 additions and 1 deletions
|
@ -440,10 +440,25 @@ static DeprecatedString read_command_line(pid_t pid)
|
|||
return string_or_error.release_value();
|
||||
}
|
||||
|
||||
ErrorOr<void> ProcessModel::initialize_process_statistics_file()
|
||||
{
|
||||
if (!m_process_statistics_file || !m_process_statistics_file->is_open())
|
||||
m_process_statistics_file = TRY(Core::File::open("/sys/kernel/processes"sv, Core::File::OpenMode::Read));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void ProcessModel::update()
|
||||
{
|
||||
auto result = initialize_process_statistics_file();
|
||||
if (result.is_error()) {
|
||||
dbgln("Process model couldn't be updated: {}", result.release_error());
|
||||
return;
|
||||
}
|
||||
|
||||
auto all_processes = Core::ProcessStatisticsReader::get_all(*m_process_statistics_file, true);
|
||||
|
||||
auto previous_tid_count = m_threads.size();
|
||||
auto all_processes = Core::ProcessStatisticsReader::get_all(true);
|
||||
|
||||
HashTable<int> live_tids;
|
||||
u64 total_time_scheduled_diff = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue