forked from StephenGrider/AdvancedNodeComplete
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultitask.js
More file actions
35 lines (28 loc) · 646 Bytes
/
multitask.js
File metadata and controls
35 lines (28 loc) · 646 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
process.env.UV_THREADPOOL_SIZE = 1;
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();