Showing posts from August, 2012

Java Stopwatch

In many cases, when programming, i want to measure the time some block of code has taken.
This functionality is needed in many projects I work on, and on each project it is sometimes needed many times.
The first few times i have done it manually, use getTimeInMillis() and deducted the end time from the starting time.
When it occurred several more times I have built a Stopwatch class, which is the path many have gone on before.
After tweaking that class several times, as my requirements became clearer to me, I have understood that I can do a decent job in the stopwatch class, but I can use a robust and maintained framework which has done a nicer job than mine, that was the stage where i went googling it out.
And i have found many classes implementing the stopwatch functionality, after narrowing them down, 3 frameworks remained: 1. Apache commons 2. Spring 3. Google's Guava
Which one did I pick? What are the differences between them?
Basically they do the same things with slight ch…