Skip to content

Instantly share code, notes, and snippets.

@muhsin-k
Created March 18, 2018 07:59
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 muhsin-k/00dbacefa42d520ce715dc898d04bc5b to your computer and use it in GitHub Desktop.
Save muhsin-k/00dbacefa42d520ce715dc898d04bc5b to your computer and use it in GitHub Desktop.
Event Loop Example
process.env.UV_THREADPOOL_SIZE = 5;
const https = require("https");
const crypto = require("crypto");
const fs = require("fs");
const start = Date.now();
function doRequest() {
https
.request("https://www.google.com", res => {
res.on("data", () => {});
res.on("end", () => {
console.log(Date.now() - start);
});
})
.end();
}
function doHash() {
crypto.pbkdf2("a", "b", 100000, 512, "sha512", () => {
console.log("Hash:", Date.now() - start);
});
}
doRequest();
fs.readFile("multitask.js", "utf8", () => {
console.log("FS:", Date.now() - start);
});
doHash();
doHash();
doHash();
doHash();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment