forked from redis/ioredis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingle_node.js
76 lines (64 loc) · 1.83 KB
/
single_node.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
73
74
75
76
'use strict';
var childProcess = require('child_process');
var Redis = require('../');
console.log('==========================');
console.log('redis: ' + require('../package.json').version);
var 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: ' + childProcess.execSync('git rev-parse --short HEAD'));
console.log('==========================');
var redisJD, redisJ;
var waitReady = function (next) {
var pending = 2;
function check() {
if (!--pending) {
next();
}
}
redisJD = new Redis({ parser: 'javascript', dropBufferSupport: true });
redisJ = new Redis({ parser: 'javascript', dropBufferSupport: false });
redisJD.on('ready', check);
redisJ.on('ready', check);
};
var quit = function () {
redisJD.quit();
redisJ.quit();
};
suite('SET foo bar', function () {
set('mintime', 5000);
set('concurrency', 300);
before(function (start) {
waitReady(start);
});
bench('javascript parser + dropBufferSupport: true', function (next) {
redisJD.set('foo', 'bar', next);
});
bench('javascript parser', function (next) {
redisJ.set('foo', 'bar', next);
});
after(quit);
});
suite('LRANGE foo 0 99', function () {
set('mintime', 5000);
set('concurrency', 300);
before(function (start) {
var redis = new Redis();
var item = [];
for (var i = 0; i < 100; ++i) {
item.push((Math.random() * 100000 | 0) + 'str');
}
redis.del('foo');
redis.lpush('foo', item, function () {
waitReady(start);
});
});
bench('javascript parser + dropBufferSupport: true', function (next) {
redisJD.lrange('foo', 0, 99, next);
});
bench('javascript parser', function (next) {
redisJ.lrange('foo', 0, 99, next);
});
after(quit);
});