Skip to content

Instantly share code, notes, and snippets.

@mmirolim
Created May 10, 2018 09:23
Show Gist options
  • Save mmirolim/bbf109c44e4f388a00b3995fe7834cd6 to your computer and use it in GitHub Desktop.
Save mmirolim/bbf109c44e4f388a00b3995fe7834cd6 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment