Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: show running time of processes #801

Merged
merged 7 commits into from
May 2, 2023

Conversation

yshui
Copy link
Contributor

@yshui yshui commented Sep 4, 2022

Description

Add a column to the processes table to show the running time of a process

Testing

If relevant, please state how this was tested. All changes must be tested to work:

If this is a code change, please also indicate which platforms were tested:

  • Windows
  • macOS
  • Linux

Checklist

If relevant, ensure the following have been met:

  • Areas your change affects have been linted using rustfmt (cargo fmt)
  • The change has been tested and doesn't appear to cause any unintended breakage
  • Documentation has been added/updated if needed (README.md, help menu, etc.)
  • The pull request passes the provided CI pipeline
  • There are no merge conflicts
  • If relevant, new tests were added (don't worry too much about coverage)

Copy link
Owner

@ClementTsang ClementTsang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes generally look fine, just one comment on whether this can be done without adding a new dependency - if it's just far easier to do or not possible without adding it, let me know.

One other question - how should uptime behave if we are, say, grouping applications with the same name? For example, if I have 10 firefox processes, do we show the uptime? Take the highest one?

Cargo.toml Outdated Show resolved Hide resolved
@ClementTsang
Copy link
Owner

I also ran it on Windows, it seems fine, though I got some... interesting results for some of the times. This might be because I'm on a VM though.

image

@yshui
Copy link
Contributor Author

yshui commented Sep 6, 2022

interesting results for some of the times

hmm, did sysinfo return invalid run time in some cases?

@yshui
Copy link
Contributor Author

yshui commented Sep 6, 2022

For example, if I have 10 firefox processes, do we show the uptime? Take the highest one?

I think we should show the sum. It's the case when a process have multiple threads, on Linux at least.

@yshui yshui force-pushed the master branch 2 times, most recently from 9b7fe90 to 33a91c9 Compare September 8, 2022 21:30
@yshui
Copy link
Contributor Author

yshui commented Sep 8, 2022

I removed chrono from dependencies.

@ClementTsang
Copy link
Owner

Rebased a bunch of stuff and added tests. Will need to still add searching for time, but I can add that.

@codecov
Copy link

codecov bot commented Apr 30, 2023

Codecov Report

Patch coverage: 34.29% and project coverage change: +0.11 🎉

Comparison is base (605314d) 28.02% compared to head (e927cd0) 28.13%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #801      +/-   ##
==========================================
+ Coverage   28.02%   28.13%   +0.11%     
==========================================
  Files          95       95              
  Lines       15923    16077     +154     
==========================================
+ Hits         4462     4524      +62     
- Misses      11461    11553      +92     
Flag Coverage Δ
macos-12 29.63% <35.85%> (+0.12%) ⬆️
ubuntu-latest 29.56% <34.97%> (+0.11%) ⬆️
windows-2019 29.68% <35.50%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/app/data_harvester/processes.rs 0.00% <0.00%> (ø)
src/app/data_harvester/processes/linux.rs 19.04% <0.00%> (-0.47%) ⬇️
src/app/data_harvester/processes/macos_freebsd.rs 0.00% <0.00%> (ø)
src/app/data_harvester/processes/windows.rs 0.00% <0.00%> (ø)
src/app/query.rs 0.00% <0.00%> (ø)
src/utils/error.rs 9.75% <ø> (ø)
src/widgets/process_table/proc_widget_column.rs 59.82% <16.66%> (-2.45%) ⬇️
src/widgets/process_table.rs 61.58% <33.33%> (-0.10%) ⬇️
src/widgets/process_table/proc_widget_data.rs 36.32% <95.45%> (+26.73%) ⬆️
src/options/process_columns.rs 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ClementTsang
Copy link
Owner

Will update documentation in a separate PR later.

@ClementTsang
Copy link
Owner

Tested on Windows - noticed that the ones with 19000 days were ~53 years, which lines up with the UNIX epoch - and yep, they were reporting a start time of 0.

I might just add a check to zero out anything that reports that (or maybe make the time field an option) to handle it.

@ClementTsang ClementTsang merged commit 80183b8 into ClementTsang:master May 2, 2023
@ClementTsang
Copy link
Owner

@all-contributors please add @yshui for code.

@allcontributors
Copy link
Contributor

@ClementTsang

I've put up a pull request to add @yshui! 🎉

@wdscxsj
Copy link

wdscxsj commented Nov 27, 2023

Is it possible to add a command-line option for this feature?

@ClementTsang
Copy link
Owner

ClementTsang commented Nov 27, 2023

@wdscxsj heads up that it might be preferable if you asked stuff like this in either a separate discussion or an issue, just to avoid pinging everyone who worked on this PR.

That said, it's currently supported via changing the config (e.g.):

[processes]
columns = ["PID", "Name", "CPU%", "Mem%", "R/s", "W/s", "T.Read", "T.Write", "User", "State", "Time"]

and I'm not really sure if I want to add it as a command-line flag for now (the command-line interface is already bloated as is). Ideally changing it on runtime will become doable whenever I get to in-app config changing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants