Created
August 12, 2015 18:09
-
-
Save kvahuja/7533cc2e4c45cd6f4c03 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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