统计方法耗时

This commit is contained in:
Guoqs
2024-11-21 17:23:19 +08:00
parent fb04fa04cd
commit 6fef3bc7ae
3 changed files with 7 additions and 1 deletions

View File

@@ -4,9 +4,11 @@ import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@Aspect
@Order(1)
@Component// 使用spring容器进行管理
@Slf4j
public class CostTimeAspect {
@@ -29,7 +31,7 @@ public class CostTimeAspect {
String methodName = joinPoint.getSignature().getName();
// 获取类名称
String className = joinPoint.getSignature().getDeclaringTypeName();
log.info("统计方法耗时, 类:[{}], 方法:[{}], 耗时时间为:[{}]", className, methodName, (System.currentTimeMillis() - beginTime) / 1000 + "");
log.info("统计方法耗时, 类:[{}], 方法:[{}], 耗时时间为:[{}ms]", className, methodName, (System.currentTimeMillis() - beginTime));
} catch (Throwable throwable) {
throwable.printStackTrace();
}