Skip to content

Commit 443c99a

Browse files
committed
fix 1G => 1.9G format output
1 parent ac9cc70 commit 443c99a

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

src/ttop/format.nim

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,8 @@ proc formatS*(a, b: int, delim = " / "): string =
4444
else:
4545
if a < 1024 and b < 1024:
4646
fmt "{n1.int} {s1}{delim}{n2.int} {s2}"
47-
elif a < 1024:
48-
fmt "{n1.int} {s1}{delim}{n2:.1f} {s2}"
4947
else:
50-
fmt "{n1:.1f} {s1}{delim}{n2.int} {s2}"
48+
fmt "{n1:.1f} {s1}{delim}{n2:.1f} {s2}"
5149

5250
proc formatSI*(a, b: int, delim = "/"): string =
5351
let (n1, s1) = formatSPair(a)

src/ttop/procfs.nim

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -618,18 +618,14 @@ proc group*(pidsInfo: PidsTable, kernel: bool): PidsTable =
618618
inc i
619619

620620
when isMainModule:
621-
template t(body: untyped): untyped =
622-
try:
623-
body
624-
except CatchableError, Defect:
625-
raise getCurrentException()
626-
627-
proc f(): int =
628-
t:
629-
100
630-
631-
echo f()
632-
# let pi = group(fi.pidsInfo)
633-
# fi.pidsInfo.clear()
634-
# for o, pi in pi:
635-
# echo o, ": ", pi.name
621+
import format
622+
let t = parseSize("2009312 kB")
623+
let f = parseSize("1147380 kB")
624+
let a = parseSize("1607008 kB")
625+
let b = parseSize("21344 kB")
626+
let c = parseSize("625488 kB")
627+
echo formatD(a, t)
628+
echo formatD(f, t)
629+
echo formatD(f + b , t)
630+
echo formatD(f + c , t)
631+
echo formatD(f + b + c , t)

ttop.nimble

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Package
22

3-
version = "1.5.6"
3+
version = "1.5.7"
44
author = "inv2004"
55
description = "Monitoring tool with historical snapshots and alerts"
66
license = "MIT"

0 commit comments

Comments
 (0)