Skip to main content
gamedev.net
🔒 Locked

Timing In Java

Started by jhwc1138 1 reply 400+ views
Original Post
jhwc1138
jhwc1138
Hi there all!! I have a programming assignment that calls for me to calculate the time it takes for a number of various sorting methods to run, and then compare the result. I know in c/c++ you can include the time.h file and use getTime()to do this. What is the timing class in Java? What package is it in? Thanks
Enigma
Enigma
java.lang.System.currentTimeMillis();

Or use the java.util.Date class.

Enigma
Big Sassy
Big Sassy
Keep in mind that currentTimeMillis() accuracy varies depending on the system. Don''t quote me on this, but on a Unix box it is accurate to 1ms. On an NT machine it is accurate to 10ms. And on an 9x machine it is accurate to 50-60ms. If you are testing the speed of each function, it probably won''t be accurate enough (unless you run the test lots of times). That''s the one major problem I have with java. I wish they''d have a high precision timer. But I''m just rambling now so I''ll stop.

***********************
          

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.