Rework humanTimeUnit() formats of meters#1583
Rework humanTimeUnit() formats of meters#1583Explorer09 wants to merge 1 commit intohtop-dev:mainfrom
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) { |
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 |
|
During the review of #1606, I noticed that the |
d1f6bed to
4ceec6b
Compare
a03626e to
6503eb4
Compare
e3090a7 to
27aba5a
Compare
27aba5a to
e07774b
Compare
9290cba to
3653421
Compare
bbf785f to
4c7cc38
Compare
2d242cb to
3faf137
Compare
a3e0c40 to
4a3e6e2
Compare
4a3e6e2 to
7a49fc2
Compare
7a49fc2 to
694cf5e
Compare
fb01aed to
a386b2b
Compare
bcdf856 to
1e5eb28
Compare
1e5eb28 to
d024c98
Compare
d024c98 to
e898ba8
Compare
e898ba8 to
8a9df16
Compare
b40324c to
4c94bf6
Compare
2debc6e to
bf5f9fa
Compare
The new time formats will print at most 6 characters (increased from 5) Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
bf5f9fa to
019ce95
Compare

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.