
-----------------------------------
B1u3z
Tue Feb 14, 2012 2:51 pm

when i try to find my run time it is always zero
-----------------------------------
long time ;
time = System.currentTimeMillis();
 ( rest of program)   
time = System.currentTimeMillis() - time  ;
JOptionPane.showMessageDialog (null, time+"ms","time", JOptionPane.WARNING_MESSAGE);

i am trying to find my run time of my program but every time i run it states that it took 0ms. can i get some help on ho to fix this

-----------------------------------
Zren
Tue Feb 14, 2012 3:12 pm

RE:when i try to find my run time it is always zero
-----------------------------------
What does the rest of your program do? The code is fine. Your program is probably just not resource intensive enough to have those two sections of code to happen in a different clock cycle.

If you want to confirm this, dump a Thread.sleep in there with it's appropritate exception handling.



public class Test {
	public static void main(String

-----------------------------------
mirhagk
Tue Feb 14, 2012 11:08 pm

RE:when i try to find my run time it is always zero
-----------------------------------
Your computer runs in gigahertz. That's trillions of operations every second, which is billions every million second. SO unless your code is a billion operations it won't show up.

-----------------------------------
Insectoid
Wed Feb 15, 2012 7:52 am

Re: RE:when i try to find my run time it is always zero
-----------------------------------
Your computer runs in gigahertz. That's trillions of operations every second, which is billions every million second. SO unless your code is a billion operations it won't show up.

Thread.sleep(1000); 

-----------------------------------
B1u3z
Wed Feb 15, 2012 12:12 pm

Re: when i try to find my run time it is always zero
-----------------------------------
thanks for the help

-----------------------------------
Insectoid
Wed Feb 15, 2012 12:40 pm

RE:when i try to find my run time it is always zero
-----------------------------------
Oh, my bad. I thought Zren was OP (as I didn't check the username) and only read the title and code snippet.
