Skip to content

Add current process cpu/memory usage to SystemInformationDiagnosticsPlugin #18135

Closed
@francisdb

Description

@francisdb

What problem does this solve or what need does it fill?

System cpu/memory is useful but current process cpu/memory is even more useful.

What solution would you like?

Adding 2 extra metrics:

  • process/cpu_usage in %core, eg 200% if 2 cores in use
  • process/mem_usage in MB

What alternative(s) have you considered?

Extending the plugin in my own app

Additional context

Following code would need to be added to fetch the info.

                let pid = sysinfo::get_current_pid().expect("Failed to get current process ID");
                sys.refresh_processes(ProcessesToUpdate::Some(&[pid]), true);

                let process_mem_usage = sys
                    .process(pid)
                    .map(|p| p.memory() as f64 / 1024.0 / 1024.0) // Convert to MB
                    .unwrap_or(0.0);

                let process_cpu_usage = sys
                    .process(pid)
                    .map(|p| p.cpu_usage() as f64)
                    .unwrap_or(0.0);

If there is interest in this I'm willing to create a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-Dev-ToolsTools used to debug Bevy applications.A-DiagnosticsLogging, crash handling, error reporting and performance analysisC-FeatureA new feature, making something new possibleD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions