Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Eladmin
Commits
20f2c636
Commit
20f2c636
authored
Jun 14, 2022
by
Zheng Jie
Browse files
[代码完善](master): 代码优化
parent
7cef6f8b
Changes
1
Hide whitespace changes
Inline
Side-by-side
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MonitorServiceImpl.java
View file @
20f2c636
...
...
@@ -148,9 +148,15 @@ public class MonitorServiceImpl implements MonitorService {
cpuInfo
.
put
(
"logic"
,
processor
.
getLogicalProcessorCount
()
+
"个逻辑CPU"
);
// CPU信息
long
[]
prevTicks
=
processor
.
getSystemCpuLoadTicks
();
// 等待1秒...
Util
.
sleep
(
1000
);
// 默认等待300毫秒...
long
time
=
300
;
Util
.
sleep
(
time
);
long
[]
ticks
=
processor
.
getSystemCpuLoadTicks
();
while
(
Arrays
.
toString
(
prevTicks
).
equals
(
Arrays
.
toString
(
ticks
))
&&
time
<
1000
){
time
+=
25
;
Util
.
sleep
(
25
);
ticks
=
processor
.
getSystemCpuLoadTicks
();
}
long
user
=
ticks
[
CentralProcessor
.
TickType
.
USER
.
getIndex
()]
-
prevTicks
[
CentralProcessor
.
TickType
.
USER
.
getIndex
()];
long
nice
=
ticks
[
CentralProcessor
.
TickType
.
NICE
.
getIndex
()]
-
prevTicks
[
CentralProcessor
.
TickType
.
NICE
.
getIndex
()];
long
sys
=
ticks
[
CentralProcessor
.
TickType
.
SYSTEM
.
getIndex
()]
-
prevTicks
[
CentralProcessor
.
TickType
.
SYSTEM
.
getIndex
()];
...
...
Write
Preview
Supports
Markdown
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