Results 1 to 4 of 4
  1. #1
    sara12345 is offline Member
    Join Date
    Dec 2009
    Posts
    59
    Rep Power
    0

    Default calculating time of program runing

    hello
    I need to calculate the time of runing program
    I have java program and I need to calculate the time of running that program
    can you tell me how to do this in java

    thanks alot

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,763
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by sara12345 View Post
    hello
    I need to calculate the time of runing program
    I have java program and I need to calculate the time of running that program
    can you tell me how to do this in java

    thanks alot
    Have you read about the currentTimeMillis() method? Not all OSes give you millisecond accuracy but a good estimation thereof; you can do:

    Java Code:
    long start= currentTimeMillis();
    // very complicated calculations go here
    long end= currentTimeMillis();
    long duration= end-start;
    kind regards,

    Jos

  3. #3
    sara12345 is offline Member
    Join Date
    Dec 2009
    Posts
    59
    Rep Power
    0

    Default

    ok thanks alot

  4. #4
    mt88's Avatar
    mt88 is offline Member
    Join Date
    Feb 2010
    Posts
    5
    Rep Power
    0

Similar Threads

  1. Help with calculating triangle program
    By ALH813 in forum New To Java
    Replies: 5
    Last Post: 10-19-2009, 06:08 AM
  2. Calculating the Running time
    By JordashTalon in forum New To Java
    Replies: 2
    Last Post: 02-13-2009, 11:32 PM
  3. Need help with calculating the time the user...
    By Smirre in forum New To Java
    Replies: 8
    Last Post: 11-20-2008, 02:15 PM
  4. Replies: 4
    Last Post: 08-12-2008, 02:41 PM
  5. Calculating the DB connection time
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-20-2008, 09:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •