Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > measuring the execution time of a java method

Reply
Thread Tools

measuring the execution time of a java method

 
 
Jeremy Watts
Guest
Posts: n/a
 
      06-14-2005
hi,

how would you measure the execution time of a java method?


 
Reply With Quote
 
 
 
 
Thomas Weidenfeller
Guest
Posts: n/a
 
      06-14-2005
Jeremy Watts wrote:
> how would you measure the execution time of a java method?


I guess you want to know how you could do it. You could e.g. run a
profiler, or use the difference of two calls to System.currentTimeMillis().

/Thomas


--
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/...g/java/gui/faq
 
Reply With Quote
 
 
 
 
Alexander Lueck
Guest
Posts: n/a
 
      06-14-2005
Jeremy Watts wrote:
> how would you measure the execution time of a java method?


long start = System.currentTimeMillis();
....
doSomething();
....
long end = System.currentTimeMillis();

System.out.println("Execution time was "+(end-start)+" ms.");

Greetings

Alex
 
Reply With Quote
 
Jeremy Watts
Guest
Posts: n/a
 
      06-14-2005

"Alexander Lueck" <al@_nospam_4pisysteme.de> wrote in message
news:d8m0ba$oe5$(E-Mail Removed)-ilmenau.de...
> Jeremy Watts wrote:
> > how would you measure the execution time of a java method?

>
> long start = System.currentTimeMillis();
> ...
> doSomething();
> ...
> long end = System.currentTimeMillis();
>
> System.out.println("Execution time was "+(end-start)+" ms.");
>
> Greetings
>
> Alex


Many thanks

Jeremy


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Measuring running time in a general + portable way upperclass C Programming 20 04-27-2007 09:47 AM
measuring running time upperclass C Programming 2 04-26-2007 04:39 AM
Measuring time differences Dominik Wallner C Programming 74 12-20-2005 04:31 PM
Measuring a short interval in time Wes Harrison Java 2 09-14-2004 05:04 PM
Measuring Class Load Time Using OptimizeIt John Raggio Java 10 03-07-2004 02:01 AM



Advertisments