Skip to content

Commit b075cd9

Browse files
Fix
1 parent a6cf8a1 commit b075cd9

File tree

1 file changed

+17
-22
lines changed

1 file changed

+17
-22
lines changed

src/TerminalSystemMonitor.jl

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ CPU usage between 0.0 and 100 [percent]
3838
The idea is borrowed from https://discourse.julialang.org/t/get-cpu-usage/24468/7
3939
Thank you @fonsp.
4040
"""
41-
function cpu_percent(period::Real=1.0)
41+
function cpu_percent(period::Real = 1.0)
4242

4343
info = Sys.cpu_info()
4444
busies = busy_time.(info)
@@ -53,7 +53,7 @@ function cpu_percent(period::Real=1.0)
5353
100 * busies ./ (idles .+ busies)
5454
end
5555

56-
function clearline(; move_up::Bool=false)
56+
function clearline(; move_up::Bool = false)
5757
buf = IOBuffer()
5858
print(buf, "\x1b[2K") # clear line
5959
print(buf, "\x1b[999D") # rollback the cursor
@@ -63,7 +63,7 @@ end
6363

6464
function clearlines(H::Integer)
6565
for i = 1:H
66-
clearline(move_up=true)
66+
clearline(move_up = true)
6767
end
6868
end
6969

@@ -77,7 +77,7 @@ end
7777

7878
function layout(x, y)
7979
ncpus = length(y)
80-
y = round.(y, digits=1)
80+
y = round.(y, digits = 1)
8181
_, cols = displaysize(stdout)
8282

8383
plts = []
@@ -86,31 +86,26 @@ function layout(x, y)
8686
for c in chunks
8787
push!(
8888
plts,
89-
barplot(
90-
x[c], y[c],
91-
# title="CPU Usage",
92-
maximum=100, width=max(5, 15), height=length(c),
93-
)
89+
barplot(x[c], y[c], maximum = 100, width = max(5, 15), height = length(c)),
9490
)
9591
end
92+
memoryusage = round((Sys.total_memory() - Sys.free_memory()) / 2^20 / 1000, digits = 1)
93+
94+
push!(
95+
plts,
96+
barplot(
97+
["Mem: "],
98+
[memoryusage],
99+
maximum = Sys.total_memory() / 2^20 / 1000,
100+
width = max(10, 40),
101+
),
102+
)
96103

97104
n = max(1, cols ÷ 25)
98105
chunks = collect(Iterators.partition(plts, n))
99106

100-
foldl(/, map(c->prod(UnicodePlots.panel.(c)), chunks))
101107

102-
chunks = collect(Iterators.partition(plts, n))
103-
104-
canvas = foldl(/, map(c->prod(UnicodePlots.panel.(c)), chunks))
105-
106-
memoryusage = round((Sys.total_memory() - Sys.free_memory()) / 2 ^ 20 / 1000, digits=1)
107-
108-
canvas / UnicodePlots.panel(barplot(
109-
["Mem: "],
110-
[memoryusage],
111-
title="Memmory $(memoryusage)/$(floor(Sys.total_memory()/2^20 / 1000)) GB",
112-
maximum=Sys.total_memory()/2^20 / 1000, width=max(10, 40)
113-
))
108+
return foldl(/, map(c -> prod(UnicodePlots.panel.(c)), chunks))
114109
end
115110

116111

0 commit comments

Comments
 (0)