-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaster.js
More file actions
44 lines (36 loc) · 1.58 KB
/
master.js
File metadata and controls
44 lines (36 loc) · 1.58 KB
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
36
37
38
39
40
41
42
43
const fs = require("node:fs"); // import file system module
const crypto = require('node:crypto');
// console.log("First line");
// handle by libuv with thread pool
// fs.readFile("./testing/test.txt", "utf8", (err, data) => {
// console.log("file content", data);
// });
const start = performance.now();
// with Sync ===========================
// crypto.pbkdf2Sync('secret', 'salt', 100000, 64, 'sha512');
// console.log("end at : ", performance.now() - start);
// crypto.pbkdf2Sync('secret', 'salt', 100000, 64, 'sha512');
// console.log("end at : ", performance.now() - start);
// crypto.pbkdf2Sync('secret', 'salt', 100000, 64, 'sha512');
// console.log("end at : ", performance.now() - start);
// without Sync ============thread pool=============== cpu tasks
// process.env.UVThREDPOOL = 10; // control on thread pool default(4threads) MAXMEM(1024threads)
crypto.pbkdf2('secret', 'salt', 100000, 64, 'sha512', () => {
console.log("end at ms : ", performance.now() - start);
});
crypto.pbkdf2('secret', 'salt', 100000, 64, 'sha512', () => {
console.log("end at ms : ", performance.now() - start);
});
crypto.pbkdf2('secret', 'salt', 100000, 64, 'sha512', () => {
console.log("end at ms : ", performance.now() - start);
});
// network tasks
fetch("https://dummyjson.com/products/1").then(() => {
console.log("end of req ms : ", performance.now() - start);
})
fetch("https://dummyjson.com/products/1").then(() => {
console.log("end of req ms : ", performance.now() - start);
})
fetch("https://dummyjson.com/products/1").then(() => {
console.log("end of req ms : ", performance.now() - start);
})