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. Advertising

  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. Advertising

  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. Advertising

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:
    782
    rpadev
    Mar 7, 2004
  2. Wes Harrison

    Measuring a short interval in time

    Wes Harrison, Sep 14, 2004, in forum: Java
    Replies:
    2
    Views:
    567
    Paul Lutus
    Sep 14, 2004
  3. Dominik Wallner

    Measuring time differences

    Dominik Wallner, Dec 16, 2005, in forum: C Programming
    Replies:
    74
    Views:
    1,660
    Richard Bos
    Dec 20, 2005
  4. upperclass
    Replies:
    20
    Views:
    566
  5. upperclass

    measuring running time

    upperclass, Apr 26, 2007, in forum: C Programming
    Replies:
    2
    Views:
    339
    Ben Pfaff
    Apr 26, 2007
Loading...

Share This Page