timer help!!


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: timer help!!

  1. #1
    Join Date
    Oct 2004
    Posts
    2

    timer help!!

    im in bad need of help! i am implementing a sorting program and i need the code for the timer.. please help me.. what can i do? when i press start the sorting the timer needs to start and stop when the list has been sorted.. how will i do it? i need to have it in nanoseconds..

  2. #2
    Join Date
    Oct 2004
    Posts
    311
    don't know about nano seconds but in case of milisecond, I would just use the following:
    System.currentTimeMiliseconds();
    This shoulod give you the current time in miliseconds (I think that's as acurate as it gets in Java tbh)

    when you get the time before and after running the sort, you can then just substract to get the duration

  3. #3
    Join Date
    Oct 2004
    Posts
    2
    I already tried that. the problem is that my program is ..sorting.. and sorts in a split of a second.. when i used system.currentTimeMillis() it only gives me 0.. because it cannot capture the system time.

  4. #4
    Join Date
    Mar 2004
    Posts
    635
    i'm not aware of being able to get time in nanoseconds.

  5. #5
    Join Date
    Sep 2004
    Posts
    223
    wouldnt you just multiply the milliseconds you have by 1000 or whatever?
    A kram a day keeps the doctor......guessing

  6. #6
    Join Date
    Mar 2004
    Posts
    635
    that would display it as nanoseconds, but wouldn't actually have the precision.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center