Skip to content

Instantly share code, notes, and snippets.

@dhet
Created December 29, 2019 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhet/66b1afc7602e2f77131ac35406dfea17 to your computer and use it in GitHub Desktop.
Save dhet/66b1afc7602e2f77131ac35406dfea17 to your computer and use it in GitHub Desktop.
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