From 6f8d38f9f52f7cdde6e56f76e2e8d09010744efc Mon Sep 17 00:00:00 2001 From: XenoAmess Date: Fri, 3 Dec 2021 15:21:46 +0800 Subject: [PATCH] numeric issues (#1982) --- .../arthas/core/command/monitor200/MonitorAdviceListener.java | 2 +- .../taobao/arthas/core/command/monitor200/ThreadSampler.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/taobao/arthas/core/command/monitor200/MonitorAdviceListener.java b/core/src/main/java/com/taobao/arthas/core/command/monitor200/MonitorAdviceListener.java index 53ab5e5742f..fe01b212ebe 100644 --- a/core/src/main/java/com/taobao/arthas/core/command/monitor200/MonitorAdviceListener.java +++ b/core/src/main/java/com/taobao/arthas/core/command/monitor200/MonitorAdviceListener.java @@ -94,7 +94,7 @@ public synchronized void create() { if (timer == null) { timer = new Timer("Timer-for-arthas-monitor-" + process.session().getSessionId(), true); timer.scheduleAtFixedRate(new MonitorTimer(monitorData, process, command.getNumberOfLimit()), - 0, command.getCycle() * 1000); + 0, command.getCycle() * 1000L); } } diff --git a/core/src/main/java/com/taobao/arthas/core/command/monitor200/ThreadSampler.java b/core/src/main/java/com/taobao/arthas/core/command/monitor200/ThreadSampler.java index da414d00f06..91fade566d3 100644 --- a/core/src/main/java/com/taobao/arthas/core/command/monitor200/ThreadSampler.java +++ b/core/src/main/java/com/taobao/arthas/core/command/monitor200/ThreadSampler.java @@ -118,7 +118,7 @@ public int compare(ThreadVO o1, ThreadVO o2) { // Compute cpu usage final HashMap cpuUsages = new HashMap(threads.size()); for (ThreadVO thread : threads) { - double cpu = sampleIntervalNanos == 0 ? 0 : (deltas.get(thread) * 10000 / sampleIntervalNanos / 100.0); + double cpu = sampleIntervalNanos == 0 ? 0 : (Math.rint(deltas.get(thread) * 10000.0 / sampleIntervalNanos) / 100.0); cpuUsages.put(thread, cpu); }