On 2.8.14 11:27 , Davide Giannella wrote:
StopwatchLogger sl = new StopwatchLogger(FooBar.class);
// ...
public void foo() {
sl.start();
// perform all sort of things
sl.split("performed some operations");
// perform other things
sl.stop("operation completed");
}
then by setting in logs the debug for o.a.j.oak.stats.StopwatchLogger
should do the trick to have some "gross" numbers around performances.
If ok, I'll create an issue an commit to trunk.
thoguhts?
One thing that concerns me is the static reference to the executor
service. It might keep the JVM from terminating properly as it is never
shut down. A better approach might be to create it on the fly in the
start method and shut it down in the stop method. If this is too much
overhead we should make it an instance field and have the class
implement Closeable.
As a further improvement it might be helpful if clients could inject the
logger instance instead of always using the StopwatchLogger one.
Michael