commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert McIntosh <rob...@bull-enterprises.com>
Subject Re: [OT] timers
Date Tue, 11 Mar 2003 17:12:25 GMT
I started out using that approach, and then wrote a simple class that 
does that via a start() and stop() method, then formats the results for 
logging and other purposes. So the output looks like "1s: 345ms". There 
are a couple of other formats for just milliseconds, just seconds, etc. 
Makes it easy to read :-)

- Robert

Shapira, Yoav wrote:

>Howdy,
>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
>overhead.
>
>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 [mailto:robert@bull-enterprises.com]
>>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
>>    
>>
>the
>  
>
>>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: commons-dev-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>>    
>>
>
>
>
>
>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: commons-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message