Skip to content

Instantly share code, notes, and snippets.

@kvahuja
Created August 12, 2015 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kvahuja/7533cc2e4c45cd6f4c03 to your computer and use it in GitHub Desktop.
Save kvahuja/7533cc2e4c45cd6f4c03 to your computer and use it in GitHub Desktop.
@Aspect
public class ProfilingAspect {
@Around("methodsToBeProfiled()")
public Object profile(ProceedingJoinPoint pjp) throws Throwable {
StopWatch sw = new StopWatch(getClass().getSimpleName());
try {
sw.start(pjp.getSignature().getName());
return pjp.proceed();
} finally {
sw.stop();
System.out.println(sw.prettyPrint());
}
}
@Pointcut("execution(public * foo..*.*(..))")
public void methodsToBeProfiled(){}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment