ronyang1985 commented on a change in pull request #8390:
URL: https://github.com/apache/dolphinscheduler/pull/8390#discussion_r806499571



##########
File path: 
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OSUtils.java
##########
@@ -134,7 +135,11 @@ public static double loadAverage() {
      */
     public static double cpuUsage() {
         CentralProcessor processor = hal.getProcessor();
-        double cpuUsage = processor.getSystemCpuLoad();
+
+        long[] preTicks = processor.getSystemCpuLoadTicks();
+        Util.sleep(1000);

Review comment:
       According to the method annotation, getSystemCpuLoadBetweenTicks(long[] 
oldTicks)) method  returns the "recent cpu usage" for the whole system by 
counting ticks between the user-provided value from a previous call. If not 
sleeping, it will always return value with 0.0D
   ```
       /**
        * Returns the "recent cpu usage" for the whole system by counting ticks 
from
        * {@link #getSystemCpuLoadTicks()} between the user-provided value from 
a
        * previous call.
        *
        * @param oldTicks
        *            A tick array from a previous call to
        *            {@link #getSystemCpuLoadTicks()}
        * @return CPU load between 0 and 1 (100%)
        */
       double getSystemCpuLoadBetweenTicks(long[] oldTicks);
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to