-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy paththreads.js
More file actions
28 lines (21 loc) · 802 Bytes
/
threads.js
File metadata and controls
28 lines (21 loc) · 802 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
process.env.UV_THREADPOOL_SIZE = 5;
const crypto = require('crypto');
const start = Date.now();
crypto.pbkdf2('a', 'b', 100000, 512, 'sha512', () => {
console.log('1:', Date.now() - start);
});
crypto.pbkdf2('a', 'b', 100000, 512, 'sha512', () => {
console.log('2:', Date.now() - start);
});
// Lets detect the presence of the 4 Threads pool from libuv
crypto.pbkdf2('a', 'b', 100000, 512, 'sha512', () => {
console.log('3:', Date.now() - start);
});
crypto.pbkdf2('a', 'b', 100000, 512, 'sha512', () => {
console.log('4:', Date.now() - start);
});
// This last entry will need to wait for the 4 calls to complete
// Because it is taking the 4 available threads inside libuv Thread pool
crypto.pbkdf2('a', 'b', 100000, 512, 'sha512', () => {
console.log('5:', Date.now() - start);
});