Quantcast
Channel: Developer Feed - Tools
Viewing all articles
Browse latest Browse all 10

Build a simple Stop Watch Timer

$
0
0

Stop Watch in JavaAt times we need to know how much time is taken to do a Task? This task can be any unit of work e.g. a method, a few lines of code, a long running code etc. This can be helpful to understand time taken to do a Task and tune it for performance reason.

A Simple Stop Watch utility can help here to do this where ever we want to make a time measurement. This utility is Thread Safe and multiple watches can be in used in parallel with no performance impact. Each task that needs to put on a stopwatch  is stored into Hashtable. 

To measure the task time, invoke StopWatch.start("TASK-NAME");

Then execute the Task and invoke StopWatch.stop("TASK-NAME"); to stop the watch. The return value of the stop method gives the time it took to execute the task.

read more


Viewing all articles
Browse latest Browse all 10

Trending Articles