Skip to content

Commit 3061e85

Browse files
author
Ruben Bridgewater
committed
Add big arrays benchmark
1 parent 7b76bfc commit 3061e85

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

benchmark/index.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,22 @@ var lorem = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, ' +
4242
'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ' +
4343
'ut aliquip ex ea commodo consequat. Duis aute irure dolor in' // 256 chars
4444
var bigStringArray = (new Array(Math.pow(2, 16) / lorem.length).join(lorem + ' ')).split(' ') // Math.pow(2, 16) chars long
45-
var startBigBuffer = new Buffer('$' + (4 * 1024 * 1024) + '\r\n' + lorem)
45+
var startBigBuffer = new Buffer('$' + (4 * 1024 * 1024) + '\r\n')
4646
var chunks = new Array(64)
4747
for (var i = 0; i < 64; i++) {
4848
chunks[i] = new Buffer(shuffle(bigStringArray).join(' ') + '.') // Math.pow(2, 16) chars long
4949
}
5050

51+
var bigArraySize = 100
52+
var bigArray = '*' + bigArraySize + '\r\n'
53+
for (i = 0; i < bigArraySize; i++) {
54+
bigArray += '$'
55+
var size = (Math.random() * 10 | 0) + 1
56+
bigArray += size + '\r\n' + lorem.slice(0, size) + '\r\n'
57+
}
58+
59+
var bigArrayBuffer = new Buffer(bigArray)
60+
5161
var parserOld = new ParserOLD({
5262
returnReply: checkReply,
5363
returnError: returnError,
@@ -162,6 +172,20 @@ suite.add('NEW CODE: * array', function () {
162172
parser.execute(arrayBuffer)
163173
})
164174

175+
// BIG ARRAYS
176+
177+
suite.add('\nOLD CODE: * bigArray', function () {
178+
parserOld.execute(bigArrayBuffer)
179+
})
180+
181+
suite.add('HIREDIS: * bigArray', function () {
182+
parserHiRedis.execute(bigArrayBuffer)
183+
})
184+
185+
suite.add('NEW CODE: * bigArray', function () {
186+
parser.execute(bigArrayBuffer)
187+
})
188+
165189
// ERRORS
166190

167191
suite.add('\nOLD CODE: * error', function () {

0 commit comments

Comments
 (0)