-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeasure.js
72 lines (66 loc) · 1.34 KB
/
measure.js
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const os = require("os");
const {
getConfig,
log,
hash,
read,
requestDns,
requestIP
} = require("./utils");
const cpus = os.cpus().length;
const DEFAULT_THREADPOOL_SIZE = 4;
const config = getConfig({
simple: {
// UV_THREADPOOL_SIZE: 4,
work: [hash]
},
single: {
UV_THREADPOOL_SIZE: 1,
work: [hash]
},
queue: {
UV_THREADPOOL_SIZE: 1,
work: [hash, hash]
},
pool: {
// UV_THREADPOOL_SIZE: 4,
work: Array(DEFAULT_THREADPOOL_SIZE).fill(hash)
},
"pool+1": {
// UV_THREADPOOL_SIZE: 1,
work: Array(DEFAULT_THREADPOOL_SIZE + 1).fill(hash)
},
"2*pool": {
// UV_THREADPOOL_SIZE: 4,
work: Array(DEFAULT_THREADPOOL_SIZE * 2).fill(hash)
},
cpus: {
UV_THREADPOOL_SIZE: cpus,
work: Array(cpus).fill(hash)
},
"cpus-2": {
UV_THREADPOOL_SIZE: cpus - 2,
work: Array(cpus - 2).fill(hash)
},
quiz: {
// UV_THREADPOOL_SIZE: 4,
work: [
read,
...Array(DEFAULT_THREADPOOL_SIZE).fill(hash),
requestDns,
requestIP
]
}
});
const { UV_THREADPOOL_SIZE, work } = config;
if (UV_THREADPOOL_SIZE) {
process.env.UV_THREADPOOL_SIZE = UV_THREADPOOL_SIZE;
}
console.log(`CPUs: ${cpus}`);
console.log(
`UV_THREADPOOL_SIZE: ${process.env.UV_THREADPOOL_SIZE ||
DEFAULT_THREADPOOL_SIZE}`
);
for (let i = 0; i < work.length; i++) {
log(work[i]);
}