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

2 months ago
2 months ago
  1. package com.example.demo.Util;
  2. import org.aspectj.lang.ProceedingJoinPoint;
  3. import org.aspectj.lang.annotation.Around;
  4. import org.aspectj.lang.annotation.Aspect;
  5. import org.springframework.stereotype.Component;
  6. /**
  7. * @program: gold-java
  8. * @ClassName ExecutionTimeAspect
  9. * @description:
  10. * @author: Ethan
  11. * @create: 202507-03 10:50
  12. * @Version 1.0
  13. **/
  14. @Aspect
  15. @Component
  16. public class ExecutionTimeAspect {
  17. @Around("execution(* com.example.demo.serviceImpl.coin.WorkbenchServiceImpl.*(..))")
  18. public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable {
  19. long start = System.currentTimeMillis();
  20. Object proceed = joinPoint.proceed();
  21. long executionTime = System.currentTimeMillis() - start;
  22. System.out.println("执行时间 " + joinPoint.getSignature() + ": " + executionTime + " ms");
  23. return proceed;
  24. }
  25. }