스프링 aop 메소드 실행시간 계산
@Component
@Aspect
public class LogAspect {
@Around(“within(com.sist.dao.*)”)
public Object timeCheck(ProceedingJoinPoint p) throws Throwable{
String str=p.getSignature().toShortString();
System.out.println(str+”시작”);
long start=System.currentTimeMillis();
try{
Object result=p.proceed();
return result;
}
finally{
long end=System.currentTimeMillis();
System.out.println(str+”종료”);
System.out.println(str+”실행시간:”+(end-start)+”ms”);
}
}
}