measuring the execution time of a java method

Discussion in 'Java' started by Jeremy Watts, Jun 14, 2005.

  1. Jeremy Watts

    Jeremy Watts Guest

    hi,

    how would you measure the execution time of a java method?
     
    Jeremy Watts, Jun 14, 2005
    #1
    1. Advertisements

  2. 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/computer-lang/java/gui/faq
     
    Thomas Weidenfeller, Jun 14, 2005
    #2
    1. Advertisements

  3. 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
     
    Alexander Lueck, Jun 14, 2005
    #3
  4. Jeremy Watts

    Jeremy Watts Guest

    "Alexander Lueck" <al@_nospam_4pisysteme.de> wrote in message
    news:d8m0ba$oe5$-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
     
    Jeremy Watts, Jun 14, 2005
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Raggio
    Replies:
    10
    Views:
    1,054
    rpadev
    Mar 7, 2004
  2. Wes Harrison

    Measuring a short interval in time

    Wes Harrison, Sep 14, 2004, in forum: Java
    Replies:
    2
    Views:
    785
    Paul Lutus
    Sep 14, 2004
  3. flamesrock
    Replies:
    8
    Views:
    818
    Hendrik van Rooyen
    Nov 24, 2006
  4. Dominik Wallner

    Measuring time differences

    Dominik Wallner, Dec 16, 2005, in forum: C Programming
    Replies:
    74
    Views:
    2,050
    Richard Bos
    Dec 20, 2005
  5. upperclass
    Replies:
    20
    Views:
    804
  6. upperclass

    measuring running time

    upperclass, Apr 26, 2007, in forum: C Programming
    Replies:
    2
    Views:
    499
    Ben Pfaff
    Apr 26, 2007
  7. John
    Replies:
    1
    Views:
    415
    Krzysiek Zaporowski
    Mar 11, 2008
  8. Juliano

    Time measuring

    Juliano, Mar 23, 2008, in forum: C++
    Replies:
    2
    Views:
    423
    Martin York
    Mar 24, 2008
Loading...