MCPcopy Create free account
hub / github.com/careercup/ctci / main

Method main

java/Chapter 9/Introduction/Fibonacci.java:17–36  ·  view source on GitHub ↗

@param args

(String[] args)

Source from the content-addressed store, hash-verified

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}

Callers

nothing calls this directly

Calls 1

fibonacciMethod · 0.95

Tested by

no test coverage detected