Pointcut: the specification of where to apply the advice. Pointcuts come in different flavors. For example, there’s a before pointcut that run the advice’s code before the actual code - and its mirror, the after pointcut. Another pointcut is applied around a function call. This is exactly what we need to do for profiling. Without further ado, here’s the source code for that:

The benefit of this approach is that developers don’t need to concern themselves with the profiling code: a team member can write the AOP code, and configure it. It takes one aspect at the end or in parallel of the development process, and all necessary functions are now automatically profiled! Even better, with LTW , one can generate a standard JAR, and the aspect(s) can be applied through a Java agent at runtime (this is not the way chosen here). In that regard, AOP is a great and proven way to address cross-cutting concerns e.g. profiling, logging, etc. to a codebase, and to cut through all the repetitive task of actually calling the required code.