Advertisement
Queses

Node Benchmark Fibonacci

Feb 24th, 2020
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const benchmark = require('nodemark');
  2.  
  3. function fib(n) {
  4.     if(n > 1){
  5.         return fib(n-1) + fib(n-2)
  6.     } else {
  7.         return n;
  8.     }
  9. }
  10.  
  11. function test() {
  12.     var results = []
  13.     for(var i = 0; i < 40; i++){
  14.         results.push(fib(i));
  15.     }
  16. }
  17.  
  18.  
  19. const result = benchmark(test);
  20. console.log(result.milliseconds())
  21. console.log(result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement