@@ -38,7 +38,7 @@ CPU usage between 0.0 and 100 [percent]
38
38
The idea is borrowed from https://discourse.julialang.org/t/get-cpu-usage/24468/7
39
39
Thank you @fonsp.
40
40
"""
41
- function cpu_percent (period:: Real = 1.0 )
41
+ function cpu_percent (period:: Real = 1.0 )
42
42
43
43
info = Sys. cpu_info ()
44
44
busies = busy_time .(info)
@@ -53,7 +53,7 @@ function cpu_percent(period::Real=1.0)
53
53
100 * busies ./ (idles .+ busies)
54
54
end
55
55
56
- function clearline (; move_up:: Bool = false )
56
+ function clearline (; move_up:: Bool = false )
57
57
buf = IOBuffer ()
58
58
print (buf, " \x 1b[2K" ) # clear line
59
59
print (buf, " \x 1b[999D" ) # rollback the cursor
63
63
64
64
function clearlines (H:: Integer )
65
65
for i = 1 : H
66
- clearline (move_up= true )
66
+ clearline (move_up = true )
67
67
end
68
68
end
69
69
77
77
78
78
function layout (x, y)
79
79
ncpus = length (y)
80
- y = round .(y, digits= 1 )
80
+ y = round .(y, digits = 1 )
81
81
_, cols = displaysize (stdout )
82
82
83
83
plts = []
@@ -86,31 +86,26 @@ function layout(x, y)
86
86
for c in chunks
87
87
push! (
88
88
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)),
94
90
)
95
91
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
+ )
96
103
97
104
n = max (1 , cols ÷ 25 )
98
105
chunks = collect (Iterators. partition (plts, n))
99
106
100
- foldl (/ , map (c-> prod (UnicodePlots. panel .(c)), chunks))
101
107
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))
114
109
end
115
110
116
111
0 commit comments