@param args
(String[] args)
| 15 | * @param args |
| 16 | */ |
| 17 | public static void main(String[] args) { |
| 18 | int max = 35; // WARNING: If you make this above 40ish, your computer may serious slow down. |
| 19 | int trials = 10; // Run code multiple times to compute average time. |
| 20 | double[] times = new double[max]; // Store times |
| 21 | |
| 22 | |
| 23 | for (int j = 0; j < trials; j++) { // Run this 10 times to compute |
| 24 | for (int i = 0; i < max; i++) { |
| 25 | long start = System.currentTimeMillis(); |
| 26 | fibonacci(i); |
| 27 | long end = System.currentTimeMillis(); |
| 28 | long time = end - start; |
| 29 | times[i] += time; |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | for (int j = 0; j < max; j++) { |
| 34 | System.out.println(j + ": " + times[j] / trials + "ms"); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | } |