forked from redis/ioredis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingle_node.ts
83 lines (72 loc) · 1.94 KB
/
single_node.ts
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
73
74
75
76
77
78
79
80
81
82
83
/* global suite set bench after */
import { execSync } from "child_process";
import Redis from "../lib/redis";
console.log("==========================");
console.log("redis: " + require("../package.json").version);
const os = require("os");
console.log("CPU: " + os.cpus().length);
console.log("OS: " + os.platform() + " " + os.arch());
console.log("node version: " + process.version);
console.log("current commit: " + execSync("git rev-parse --short HEAD"));
console.log("==========================");
let redisJD, redisJ;
const waitReady = function (next) {
let pending = 2;
function check() {
if (!--pending) {
next();
}
}
redisJD = new Redis({ dropBufferSupport: true });
redisJ = new Redis({ dropBufferSupport: false });
redisJD.on("ready", check);
redisJ.on("ready", check);
};
const quit = function () {
redisJD.quit();
redisJ.quit();
};
suite("SET foo bar", function () {
// @ts-ignore
set("mintime", 5000);
// @ts-ignore
set("concurrency", 300);
before(function (start) {
waitReady(start);
});
// @ts-ignore
bench("javascript parser + dropBufferSupport: true", function (next) {
redisJD.set("foo", "bar", next);
});
// @ts-ignore
bench("javascript parser", function (next) {
redisJ.set("foo", "bar", next);
});
after(quit);
});
suite("LRANGE foo 0 99", function () {
// @ts-ignore
set("mintime", 5000);
// @ts-ignore
set("concurrency", 300);
before(function (start) {
const redis = new Redis();
const item = [];
for (let i = 0; i < 100; ++i) {
item.push(((Math.random() * 100000) | 0) + "str");
}
redis.del("foo");
redis.lpush("foo", item, function () {
waitReady(start);
});
});
// @ts-ignore
bench("javascript parser + dropBufferSupport: true", function (next) {
redisJD.lrange("foo", 0, 99, next);
});
// @ts-ignore
bench("javascript parser", function (next) {
redisJ.lrange("foo", 0, 99, next);
});
after(quit);
});