-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
43 lines (37 loc) · 1.13 KB
/
index.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
const { performance } = require("perf_hooks");
const hdr = require("hdr-histogram-js");
const Redis = require('ioredis')
const delay = ms => new Promise(resolve => setTimeout(resolve, ms))
const options = {
host: 'END_POINT',
port: 6379,
// password: ''
};
const total = 10000;
async function benchReuse() {
const client = new Redis(options);
const hist = hdr.build();
for (let index = 0; index < total; index++) {
let start = performance.now() * 1000 // to μs
client.ping()
let end = performance.now() * 1000 // to μs
hist.recordValue(end-start)
await delay(10)
}
client.quit()
console.log(hist.outputPercentileDistribution(1, 1));
}
async function bench() {
const hist = hdr.build();
for (let index = 0; index < total; index++) {
let start = performance.now() * 1000 // to μs
const client = new Redis(options);
client.ping()
client.quit()
let end = performance.now() * 1000 // to μs
hist.recordValue(end-start)
await delay(10)
}
console.log(hist.outputPercentileDistribution(1, 1));
}
bench();