-
-
Notifications
You must be signed in to change notification settings - Fork 439
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
Rewrite Row_printTime() with various improvements #1325
Conversation
Examples of all formats:
|
f6e55b9
to
0f05b54
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions. No perf testing done re mod/div vs. div & mul+sub.
How much of this code could we potentially re-use for #1288 time printing
0f05b54
to
33ecaf0
Compare
With zero padding the formats will now look like this:
Unfortunately I don't think there is potential for code reuse. The time factoring logic would be slightly different between two functions, but at least we can keep variable naming consistent. |
* Change variable types of time values from signed to unsigned. * Change variable naming for consistency: `totalMinutes`, `totalHours`, `totalDays` for total values and `minutes`, `hours`, `days`, etc. for remainder values. (`years` remains an exception as there is no larger unit than years) * Use `unsigned long long` type for `years` value to prevent a potential overflow. * The time units are now evaluated from small to large, in the hopes that small values would print faster. (There is no performance test for this claim.) * The days unit is now printed when `totalHours` is at least 24. (Issue htop-dev#1317) There is room in the new code to revert to the old threshold (totalHours < 2400). Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
33ecaf0
to
22c5aa4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, though I think that final branch and 'eternity' string is a bit over the top :P (could've just gone up to 9999999y and used that for anything above 1million years).
@natoscott Just to say the "eternity" idea was not mine. It was there since commit ec809b7. Credit @BenBE for that one. |
totalMinutes
,totalHours
,totalDays
for total values andminutes
,hours
,days
, etc. for remainder values.years
value to prevent a potential overflow.