You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
886 B

package com.example.demo.Util;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
/**
* @program: gold-java
* @ClassName ExecutionTimeAspect
* @description:
* @author: Ethan
* @create: 2025−07-03 10:50
* @Version 1.0
**/
@Aspect
@Component
public class ExecutionTimeAspect {
@Around("execution(* com.example.demo.serviceImpl.coin.WorkbenchServiceImpl.*(..))")
public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable {
long start = System.currentTimeMillis();
Object proceed = joinPoint.proceed();
long executionTime = System.currentTimeMillis() - start;
System.out.println("执行时间 " + joinPoint.getSignature() + ": " + executionTime + " ms");
return proceed;
}
}