Skip to content

Instantly share code, notes, and snippets.

@dhet dhet/eventloop-lag-all.js Secret
Created Dec 29, 2019

Embed
What would you like to do?
function measureLag(iteration) {
const start = new Date()
setTimeout(() => {
const lag = new Date() - start
console.log(`Loop ${iteration} took\t${lag} ms`)
measureLag(iteration + 1) // Recurse
})
}
measureLag(1)
const bcrypt = require("bcryptjs")
// const bcrypt= require("bcrypt")
function hash() {
const start = new Date()
const hashRounds = 10 // The more hash rounds the longer hashing takes
bcrypt.hash("hash me!", hashRounds, () => {
console.log(`--------- Hashing took ${new Date() - start} ms`)
setTimeout(hash)
});
}
hash()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.