JAVA Timer

Does anyone know how to put a timer into a JAVA program? I want to time how long a computation takes from start to finish and then print the result to the command window.

Thanks.

Comments

  • : Does anyone know how to put a timer into a JAVA program? I want to time how long a computation takes from start to finish and then print the result to the command window.
    :
    : Thanks.
    :
    [code]
    long start = System.currentTimeMillis();
    //some operation
    long end = System.currentTimeMillis();
    long timeInMilliseconds = end - start;
    [/code]

    ---------------------------------
    [size=1]HOWTO ask questions: http://catb.org/~esr/faqs/smart-questions.html[/size]

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion