Skip to content

Instantly share code, notes, and snippets.

@mmirolim
Created May 10, 2018 09:23
Show Gist options
  • Select an option

  • Save mmirolim/bbf109c44e4f388a00b3995fe7834cd6 to your computer and use it in GitHub Desktop.

Select an option

Save mmirolim/bbf109c44e4f388a00b3995fe7834cd6 to your computer and use it in GitHub Desktop.

Revisions

  1. mmirolim created this gist May 10, 2018.
    31 changes: 31 additions & 0 deletions bench-node.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    const { performance } = require('perf_hooks');

    const fibo = fib()

    function fib() {
    let x = 0
    let y = 1
    return function () {
    const temp = x;
    x = x + y;
    y = temp;
    return y
    }
    }
    var text = 'For more information, see Chapter 3.4.5.1'
    var t0 = performance.now();
    for (let j=0; j<100; j++) {
    for (let i=0; i<100; i++){
    str = new Date()
    d = new Date(str)
    found = text.match(/see (chapter \d+(\.\d)*)/i);
    console.log(fibo(), str.toString(), found, d)
    }
    }
    var t1 = performance.now();
    console.log("Call to doSomething took " + (t1 - t0) + " milliseconds.");

    // standart x1 770 ms
    // laptop asus 620 ms
    // c5.large 570 ms
    // m5.large 620 ms