That's not what the program does. The second argument (k) is used as the value to find; it's not randomly generated.Originally posted by Neil Forrest:
two arguments are entered on the command line: ... and number of searches(k);the program generates a random search value.
Originally posted by David Harkness:
That's not what the program does. The second argument (k) is used as the value to find; it's not randomly generated.
As to the time being short, what values of n have you used? For small values (less than 1000000) on modern hardware I wouldn't be surprised if the granularity of the timing in JDK pre 1.5 shows it to take 0 ms. You'll notice that pre 1.5 (or is it 1.4?) the smallest differences in System.currentTimeMillis() are 15 and 16 milliseconds, otherwise it's zero.
You're iterating an array and doing an int increment and comparison for each iteration. This takes very little time.
I would think so, yes. But running the same code on the same hardware and OS yielded different granularity when I upgraded from 1.3 to 1.4, and I've seen the 15/16 ms granularity since Java's beginning on different hardware.Originally posted by Layne Lund:
Isn't the granularity dependant on the underlying hardware as well as the JDK?
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |