At some point or another everyone writes a timing aspect. It’s simple yet fun. Here’s mine. This is a timing aspect with a small difference. There exists an annotation called @Timed and you can apply that annotation at a class level or method level and accordingly the invocations shall be timed and the output printed to stdout. Although it is intended to be illustrative to a degree it hopefully offers some utility value also.
The following aspect acts on annotated classes and methods and times invocations producing output to stdout (which can be changed easily to a logger). In the background it uses Spring AOP driven by jdk proxies or cglib proxies depending on what the attribute
proxy-target-class is set to in the spring xml.