arthas
arthas copied to clipboard
使用trace如何查看lamda里面的调用时间
ThreadPoolExecutor executor = new ThreadPoolExecutor(10, 50, 60, TimeUnit.SECONDS,
new SynchronousQueue<>(),
Executors.defaultThreadFactory(),
new ThreadPoolExecutor.CallerRunsPolicy()
);
@KafkaListener(topics = "writeData")
public void writeData(String message){
executor.execute(() -> {
xxxxxx
xxxxxxx
});
}
使用trace如何查看lamda里面的调用时间? trace writeData 不能打印内部具体的时间
同问,在调试过程中也发现了这个问题,trace 树中没有展示 lambda 表达式中的执行时间,不知道 Arthas 有没有解决方案?
public static void main(String[] args) throws IOException {
System.in.read();
method1();
}
private static void method1() {
for (int i = 0; i < 100; i++) {
Optional.ofNullable(i)
.map(String::valueOf)
.ifPresent(num -> {
try {
int sleep = (int) (Math.random() * 50);
System.out.printf("当前第%s次运行,休眠%dms%n", num, sleep);
TimeUnit.MILLISECONDS.sleep(sleep);
} catch (InterruptedException e) {
// do nothing
}
});
}
}
Arthas 命令
trace org.example.Main method1
执行效果:
jvm自身不支持增加 lambda类,arthas内部都是统一过滤掉。