commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <>
Subject RE: [OT] timers
Date Tue, 11 Mar 2003 17:02:43 GMT

I tend to use the simplest of all:

long opStart = System.currentTimeMillis();
... do stuff ...
long opEnd = System.currentTimeMillis();
... elapsed time in milliseconds = opEnd - opStart

I know this approach isn't 100% accurate due to threading issues, CPU
cycles, etc, but it's good enough for every application I've ever
written/used.  It's also consistent, simple to use, and incurs no

You will undoubtedly find many timing utilities if you try a google
search.  I haven't found one that claims to always be 100% accurate in
the face of threading issues, so why bother using anything but the
simplest? ;)

Yoav Shapira
Millennium ChemInformatics

>-----Original Message-----
>From: Robert McIntosh []
>Sent: Tuesday, March 11, 2003 11:54 AM
>To: Commons
>Subject: [OT] timers
>Does anyone know of a good timer utility, maybe there is one hidden in
>commons somewhere? I don't mean a timer like the java.util.Timer and
>javax.swing.Timers which are schedule types, but a timer for well,
>timing operations. I have a simple one I wrote that works, but I didn't
>know if there were any others that might be better.
>- Robert
>To unsubscribe, e-mail:
>For additional commands, e-mail:

This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged.  This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else.  If you are not the(an) intended recipient, please immediately
delete this e-mail from your computer system and notify the sender.  Thank you.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message