From 79714b8d387065382a8a13e932637e6b94d4b974 Mon Sep 17 00:00:00 2001 From: Hearen Date: Sat, 13 Oct 2018 11:10:38 +0800 Subject: [PATCH] adding time cost for watching methods --- .../core/command/monitor200/WatchAdviceListener.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/com/taobao/arthas/core/command/monitor200/WatchAdviceListener.java b/core/src/main/java/com/taobao/arthas/core/command/monitor200/WatchAdviceListener.java index dcd655a0213..7bda4dcce83 100644 --- a/core/src/main/java/com/taobao/arthas/core/command/monitor200/WatchAdviceListener.java +++ b/core/src/main/java/com/taobao/arthas/core/command/monitor200/WatchAdviceListener.java @@ -1,9 +1,9 @@ package com.taobao.arthas.core.command.monitor200; -import com.taobao.arthas.core.advisor.ReflectAdviceListenerAdapter; -import com.taobao.arthas.core.shell.command.CommandProcess; import com.taobao.arthas.core.advisor.Advice; import com.taobao.arthas.core.advisor.ArthasMethod; +import com.taobao.arthas.core.advisor.ReflectAdviceListenerAdapter; +import com.taobao.arthas.core.shell.command.CommandProcess; import com.taobao.arthas.core.util.DateUtils; import com.taobao.arthas.core.util.LogUtil; import com.taobao.arthas.core.util.StringUtils; @@ -11,9 +11,6 @@ import com.taobao.arthas.core.view.ObjectView; import com.taobao.middleware.logger.Logger; -import java.text.SimpleDateFormat; -import java.util.Date; - /** * @author beiwei30 on 29/11/2016. */ @@ -85,7 +82,7 @@ private void watching(Advice advice) { Object value = getExpressionResult(command.getExpress(), advice, cost); String result = StringUtils.objectToString( isNeedExpand() ? new ObjectView(value, command.getExpand(), command.getSizeLimit()).draw() : value); - process.write("ts=" + DateUtils.getCurrentDate() + ";result=" + result + "\n"); + process.write("ts=" + DateUtils.getCurrentDate() + "; [cost=" + cost + "ms] result=" + result + "\n"); process.times().incrementAndGet(); if (isLimitExceeded(command.getNumberOfLimit(), process.times().get())) { abortProcess(process, command.getNumberOfLimit());