Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
liming6
dcu-process-montor
Commits
2636b033
Commit
2636b033
authored
Dec 04, 2025
by
liming6
Browse files
fix 修改背景信息更新频率
parent
b87220dd
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
6 deletions
+21
-6
cmd/hytop/backend/dcu.go
cmd/hytop/backend/dcu.go
+1
-1
cmd/hytop/tui/dcuinfo.go
cmd/hytop/tui/dcuinfo.go
+2
-1
cmd/hytop/tui/process_detail.go
cmd/hytop/tui/process_detail.go
+1
-2
cmd/hytop/tui/timechart.go
cmd/hytop/tui/timechart.go
+1
-2
cmd/hytop/tui/tui_test.go
cmd/hytop/tui/tui_test.go
+16
-0
No files found.
cmd/hytop/backend/dcu.go
View file @
2636b033
...
@@ -62,7 +62,7 @@ func Init() error {
...
@@ -62,7 +62,7 @@ func Init() error {
if
err
==
nil
{
if
err
==
nil
{
stopCtx
,
cancelFunc
=
context
.
WithCancel
(
context
.
Background
())
stopCtx
,
cancelFunc
=
context
.
WithCancel
(
context
.
Background
())
go
func
()
{
go
func
()
{
ticker
:=
time
.
NewTicker
(
time
.
Second
*
20
)
ticker
:=
time
.
NewTicker
(
time
.
Second
*
8
)
for
{
for
{
select
{
select
{
case
<-
ticker
.
C
:
case
<-
ticker
.
C
:
...
...
cmd/hytop/tui/dcuinfo.go
View file @
2636b033
...
@@ -100,7 +100,8 @@ func (m *ModelDCUInfo) View() string {
...
@@ -100,7 +100,8 @@ func (m *ModelDCUInfo) View() string {
borderStr
=
LowLeightStyle
.
Render
(
borderStr
)
borderStr
=
LowLeightStyle
.
Render
(
borderStr
)
}
}
infos
:=
make
([]
string
,
0
)
infos
:=
make
([]
string
,
0
)
for
i
:=
range
64
{
for
i
:=
range
32
{
qinfo
,
haveq
:=
qmap
[
i
]
qinfo
,
haveq
:=
qmap
[
i
]
sinfo
,
haves
:=
smap
[
i
]
sinfo
,
haves
:=
smap
[
i
]
if
!
(
haveq
||
haves
)
{
if
!
(
haveq
||
haves
)
{
...
...
cmd/hytop/tui/process_detail.go
View file @
2636b033
...
@@ -186,11 +186,10 @@ func (m *ModelProcessDetail) handleModelMsg(msg *ModelMsg) {
...
@@ -186,11 +186,10 @@ func (m *ModelProcessDetail) handleModelMsg(msg *ModelMsg) {
m
.
maxValThreshold
[
0
]
=
float64
(
int
(
math
.
Ceil
(
cpu
))
/
50
)
*
50
+
50
m
.
maxValThreshold
[
0
]
=
float64
(
int
(
math
.
Ceil
(
cpu
))
/
50
)
*
50
+
50
}
}
m
.
CPU
=
NewTimeChart
(
m
.
w
[
0
],
m
.
h
[
0
],
0
,
m
.
maxValThreshold
[
0
],
[]
lipgloss
.
Color
{
lipgloss
.
Color
(
"#00fffbff"
)})
m
.
CPU
=
NewTimeChart
(
m
.
w
[
0
],
m
.
h
[
0
],
0
,
m
.
maxValThreshold
[
0
],
[]
lipgloss
.
Color
{
lipgloss
.
Color
(
"#00fffbff"
)})
m
.
CPU
.
Put
Point
(
m
.
cpuPoints
.
Values
())
m
.
CPU
.
Update
(
MyTimeChartMsg
{
Reset
:
false
,
Point
s
:
m
.
cpuPoints
.
Values
()
}
)
}
else
{
}
else
{
m
.
CPU
.
Update
(
MyTimeChartMsg
{
Reset
:
false
,
Points
:
[]
tchart
.
TimePoint
{{
Time
:
msg
.
t
,
Value
:
cpu
}}})
m
.
CPU
.
Update
(
MyTimeChartMsg
{
Reset
:
false
,
Points
:
[]
tchart
.
TimePoint
{{
Time
:
msg
.
t
,
Value
:
cpu
}}})
}
}
}
}
func
(
m
*
ModelProcessDetail
)
View
()
string
{
func
(
m
*
ModelProcessDetail
)
View
()
string
{
...
...
cmd/hytop/tui/timechart.go
View file @
2636b033
...
@@ -175,7 +175,7 @@ func (m *MyTimeChart) PutPoint(points []tchart.TimePoint) {
...
@@ -175,7 +175,7 @@ func (m *MyTimeChart) PutPoint(points []tchart.TimePoint) {
func
(
m
*
MyTimeChart
)
ResetPutPoint
(
points
[]
tchart
.
TimePoint
)
{
func
(
m
*
MyTimeChart
)
ResetPutPoint
(
points
[]
tchart
.
TimePoint
)
{
// 清除原有的点
// 清除原有的点
m
.
lockPoints
.
Lock
()
m
.
lockPoints
.
Lock
()
m
.
points
=
nil
m
.
points
=
m
.
points
[
:
0
]
// 排序输入数据
// 排序输入数据
sort
.
Slice
(
points
,
func
(
i
,
j
int
)
bool
{
sort
.
Slice
(
points
,
func
(
i
,
j
int
)
bool
{
...
@@ -199,7 +199,6 @@ func (m *MyTimeChart) ResetPutPoint(points []tchart.TimePoint) {
...
@@ -199,7 +199,6 @@ func (m *MyTimeChart) ResetPutPoint(points []tchart.TimePoint) {
m
.
points
=
append
(
make
([]
tchart
.
TimePoint
,
0
,
len
(
points
[
index
:
])),
points
[
index
:
]
...
)
m
.
points
=
append
(
make
([]
tchart
.
TimePoint
,
0
,
len
(
points
[
index
:
])),
points
[
index
:
]
...
)
}
else
if
first
.
After
(
threshold
)
{
}
else
if
first
.
After
(
threshold
)
{
// 需要补充数据
// 需要补充数据
m
.
points
=
make
([]
tchart
.
TimePoint
,
0
,
len
(
points
)
+
2
*
m
.
width
+
1
)
max
:=
m
.
width
*
2
max
:=
m
.
width
*
2
for
i
:=
1
;
i
<
max
;
i
++
{
for
i
:=
1
;
i
<
max
;
i
++
{
ta
:=
now
.
Add
(
time
.
Second
*
time
.
Duration
(
-
i
))
ta
:=
now
.
Add
(
time
.
Second
*
time
.
Duration
(
-
i
))
...
...
cmd/hytop/tui/tui_test.go
View file @
2636b033
...
@@ -3,6 +3,8 @@ package tui
...
@@ -3,6 +3,8 @@ package tui
import
(
import
(
"fmt"
"fmt"
"get-container/cmd/hytop/backend"
"get-container/cmd/hytop/backend"
"get-container/cmd/hytop/tchart"
"math/rand/v2"
"testing"
"testing"
"time"
"time"
...
@@ -75,3 +77,17 @@ func TestSysloadInit(t *testing.T) {
...
@@ -75,3 +77,17 @@ func TestSysloadInit(t *testing.T) {
t
.
Logf
(
"%d ms"
,
tt
.
Sub
(
ts
[
0
])
.
Milliseconds
())
t
.
Logf
(
"%d ms"
,
tt
.
Sub
(
ts
[
0
])
.
Milliseconds
())
}
}
}
}
func
TestTimeChart
(
t
*
testing
.
T
)
{
chart1
:=
NewTimeChart
(
100
,
20
,
0
,
100
,
nil
)
chart2
:=
NewTimeChart
(
100
,
20
,
0
,
100
,
nil
)
now
:=
time
.
Now
()
points
:=
make
([]
tchart
.
TimePoint
,
0
,
200
)
for
i
:=
range
200
{
points
=
append
(
points
,
tchart
.
TimePoint
{
Time
:
now
.
Add
(
time
.
Duration
(
-
i
)
*
time
.
Second
),
Value
:
rand
.
Float64
()
*
100
})
}
chart1
.
PutPoint
(
points
)
t
.
Logf
(
"
\n
%s"
,
chart1
.
View
())
chart2
.
PutPoint
(
points
)
t
.
Logf
(
"
\n
%s"
,
chart2
.
View
())
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment