Sometimes one may want to measure execution time of a method. In such case he
may surround it's body with tr ... finally:
public int myMethod() {
Split s = SimonManager.getStopwatch("myMethod").start();
try {
// method body
return 1;
} finally {
s.stop();
}
}
I suggest to modify 'Split' class so it implements either AutoCloseable
(available since java 1.7) or Closeable (available since java 1.5) interface.
In close() method implementation it will simply call stop() method. This will
do a great job to improve readability in above case because it can be wrapped
in try with resources if java runtime environment version is >= 1.7. The code
will look like:
public int myMethod() {
try (Split s = SimonManager.getStopwatch("myMethod").start()) {
// method body
return 1;
}
}
I think it's an easy task. I can do a pull request or so. What do you think?
Original issue reported on code.google.com by vitava...@gmail.com on 24 Jul 2014 at 10:44
Original issue reported on code.google.com by
vitava...@gmail.com
on 24 Jul 2014 at 10:44