Benchmarking is important, I feel there’s not enough is the easiest way to get started with the Closure . I honestly didn’t want to install it locally if they offered a free, quick and online service. I chose the Simple Optimization, choosing the Advanced mode would remove the Fibonacci function, after all, nothing is being done with the result. Closure Compiler Service Compiler Let’s it… benchmark Original Code (standard style, ES6 const/let) time = process.hrtime() const fib (n) { (n < 2) n fib(n - 2) + fib(n - 1)} function if return return ( i = 0; i < 10; i++) { // 10 iterations ( n = 0; n < 37; n++) { // fib(0) ... fib(40)fib(n)}} for let for let diff = process.hrtime(time)console.log(`Benchmark took ${diff[0]}s, ${diff[1]}ns`)diff = (diff[0] * 1e9 + diff[1]) / 10diff = [Math.floor(diff / 1e9), Math.floor(diff % 1e9)] let console.log(`Benchmark took ${diff[0]}s, ${diff[1]}ns per iteration`) Results: ➜ node original.10.jsBenchmark took 6s, 140681979nsBenchmark took 0s, 614068197ns per iteration Closure Compiler version: time = process.hrtime(); fib(a) { 2 > a ? a : fib(a - 2) + fib(a - 1);} ( i = 0;10 > i;i++) { ( n = 0;37 > n;n++) {fib(n);}} diff = process.hrtime(time);console.log("Benchmark took " + diff[0] + "s, " + diff[1] + "ns");diff = (1e9 * diff[0] + diff[1]) / 10;diff = [Math.floor(diff / 1e9), Math.floor(diff % 1e9)];console.log("Benchmark took " + diff[0] + "s, " + diff[1] + "ns per iteration"); var function return for var for var var Results: ➜ node compiled.10.jsBenchmark took 6s, 334487173nsBenchmark took 0s, 633448717ns per iteration I ran the test many times. Compiler version is slower. Maybe not by a lot (~3%), but slower. If we were to actually run fibonacci for real stuff, we would use a cache with preinitialized hard-coded values: // First 79 values for fibonacci's functionconst cache = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610,987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393,196418, 317811, 514229, 832040, 1346269, 2178309, 3524578, 5702887, 9227465,14930352, 24157817, 39088169, 63245986, 102334155, 165580141, 267914296,433494437, 701408733, 1134903170, 1836311903, 2971215073, 4807526976,7778742049, 12586269025, 20365011074, 32951280099, 53316291173, 86267571272,139583862445, 225851433717, 365435296162, 591286729879, 956722026041,1548008755920, 2504730781961, 4052739537881, 6557470319842, 10610209857723,17167680177565, 27777890035288, 44945570212853, 72723460248141,117669030460994, 190392490709135, 308061521170129, 498454011879264,806515533049393, 1304969544928657, 2111485077978050, 3416454622906707,5527939700884757, 8944394323791464] function fib (n) {return cache[n] !== undefined ? cache[n] : fib(n-2) + fib (n-1)} is how hackers start their afternoons. We’re a part of the family. We are now and happy to opportunities. Hacker Noon @AMI accepting submissions discuss advertising &sponsorship To learn more, , , or simply, read our about page like/message us on Facebook tweet/DM @HackerNoon. If you enjoyed this story, we recommend reading our and . Until next time, don’t take the realities of the world for granted! latest tech stories trending tech stories