@Component @Aspect public class ProjectAdvice { @Pointcut("execution(* com.zx.service.*Service.*(..))") private void servicePt(){} @Around("servicePt()") public void runSpeed(Procee dingJoinPoint pjp){ Signature signature = pjp.getSignature(); String className = signature.getDeclaringTypeName(); String methodName = signature.getName(); long start = System.currentTimeMillis(); for (int i = 0; i < 10000; i++) { pjp.proceed(); } long end = System.currentTimeMillis(); System.out.println("万次执行:"+ className+"."+methodName+"---->" +(end-start) + "ms"); } }
|