-
-
Notifications
You must be signed in to change notification settings - Fork 452
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
Rework humanTimeUnit() formats of meters #1583
base: main
Are you sure you want to change the base?
Conversation
A few comments:
diff --git a/linux/GPUMeter.c b/linux/GPUMeter.c
index 6854eaf3..5614eb46 100644
--- a/linux/GPUMeter.c
+++ b/linux/GPUMeter.c
@@ -40,7 +40,7 @@ static const int GPUMeter_attributes[] = {
static int humanTimeUnit(char* buffer, size_t size, unsigned long long totalNanoseconds) {
if (totalNanoseconds < 10000)
- return xSnprintf(buffer, size, "%4uns", (unsigned int)totalNanoseconds);
+ return xSnprintf(buffer, size, "%uns", (unsigned int)totalNanoseconds);
unsigned long long value = totalNanoseconds / 100;
@@ -50,7 +50,7 @@ static int humanTimeUnit(char* buffer, size_t size, unsigned long long totalNano
value /= 10; // microseconds
if (value < 10000)
- return xSnprintf(buffer, size, "%4uus", (unsigned int)value);
+ return xSnprintf(buffer, size, "%uus", (unsigned int)value);
value /= 100;
@@ -69,22 +69,22 @@ static int humanTimeUnit(char* buffer, size_t size, unsigned long long totalNano
value = totalSeconds;
if (value < 3600)
- return xSnprintf(buffer, size, "%2um%02us", (unsigned int)value / 60, (unsigned int)value % 60);
+ return xSnprintf(buffer, size, "%um%02us", (unsigned int)value / 60, (unsigned int)value % 60);
value /= 60; // minutes
if (value < 1440)
- return xSnprintf(buffer, size, "%2uh%02um", (unsigned int)value / 60, (unsigned int)value % 60);
+ return xSnprintf(buffer, size, "%uh%02um", (unsigned int)value / 60, (unsigned int)value % 60);
value /= 60; // hours
if (value < 2400)
- return xSnprintf(buffer, size, "%2ud%02uh", (unsigned int)value / 24, (unsigned int)value % 24);
+ return xSnprintf(buffer, size, "%ud%02uh", (unsigned int)value / 24, (unsigned int)value % 24);
value /= 24; // days
if (value < 365)
- return xSnprintf(buffer, size, "%5ud", (unsigned int)value);
+ return xSnprintf(buffer, size, "%ud", (unsigned int)value);
if (value < 3650)
return xSnprintf(buffer, size, "%uy%03ud", (unsigned int)(value / 365), (unsigned int)(value % 365));
@@ -92,9 +92,9 @@ static int humanTimeUnit(char* buffer, size_t size, unsigned long long totalNano
value /= 365; // years (ignore leap years)
if (value < 100000)
- return xSnprintf(buffer, size, "%5luy", (unsigned long)value);
+ return xSnprintf(buffer, size, "%luy", (unsigned long)value);
- return xSnprintf(buffer, size, " inf.");
+ return xSnprintf(buffer, size, "inf");
}
static void GPUMeter_updateValues(Meter* this) { |
d5b9506
to
359ae38
Compare
The new time formats will print at most 6 characters (increased from 5) Signed-off-by: Kang-Che Sung <[email protected]>
359ae38
to
602d4f4
Compare
Building a htop with your patch
I still see "2h02:07" in the GPU_TIME column and "313043ns". What am I doing wrong? /DLange |
Well. This patch is not about the GPU_TIME column but the time values displayed in the GPU meter. So you are probably looking at the wrong place. Enable a GPU meter in the meters menu to see it. |
That only shows me a usage "%". But in any case why is |
@fasterit Sorry, but I have only an emulator at the moment. You should set the GPU meter to text mode to see the time. It's not displayed in the bar mode. I made this PR as a follow-up to #1288. The |
The
humanTimeUnit()
function is currently used only in GPUMeter for Linux. (#1288) This is my proposal of a new time format and the code of printing it.Before
After
Comparing to the discussion I left in that PR, in this proposal I use 6 characters maximum (increased from 5). The main motive was to make the "hours + minutes" or "minutes + seconds" presentation clear without ambiguity.