Skip to content

Commit 6f82d62

Browse files
author
Ruben Bridgewater
committed
Add additional benchmarks for returning buffers and stringNumbers
1 parent 4001891 commit 6f82d62

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

benchmark/index.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,20 @@ var parser = new Parser({
8181
returnFatalError: returnError
8282
})
8383

84+
var parserBuffer = new Parser({
85+
returnReply: checkReply,
86+
returnError: returnError,
87+
returnFatalError: returnError,
88+
returnBuffers: true
89+
})
90+
91+
var parserStr = new Parser({
92+
returnReply: checkReply,
93+
returnError: returnError,
94+
returnFatalError: returnError,
95+
stringNumbers: true
96+
})
97+
8498
// BULK STRINGS
8599

86100
suite.add('OLD CODE: multiple chunks in a bulk string', function () {
@@ -107,6 +121,14 @@ suite.add('NEW CODE: multiple chunks in a bulk string', function () {
107121
parser.execute(endBuffer)
108122
})
109123

124+
suite.add('NEW BUF: multiple chunks in a bulk string', function () {
125+
parserBuffer.execute(startBuffer)
126+
parserBuffer.execute(chunkBuffer)
127+
parserBuffer.execute(chunkBuffer)
128+
parserBuffer.execute(chunkBuffer)
129+
parserBuffer.execute(endBuffer)
130+
})
131+
110132
// CHUNKED STRINGS
111133

112134
suite.add('\nOLD CODE: multiple chunks in a string', function () {
@@ -124,6 +146,11 @@ suite.add('NEW CODE: multiple chunks in a string', function () {
124146
parser.execute(chunkedStringPart2)
125147
})
126148

149+
suite.add('NEW BUF: multiple chunks in a string', function () {
150+
parserBuffer.execute(chunkedStringPart1)
151+
parserBuffer.execute(chunkedStringPart2)
152+
})
153+
127154
// BIG BULK STRING
128155

129156
suite.add('\nOLD CODE: 4mb bulk string', function () {
@@ -150,6 +177,14 @@ suite.add('NEW CODE: 4mb bulk string', function () {
150177
parser.execute(endBuffer)
151178
})
152179

180+
suite.add('NEW BUF: 4mb bulk string', function () {
181+
parserBuffer.execute(startBigBuffer)
182+
for (var i = 0; i < 64; i++) {
183+
parserBuffer.execute(chunks[i])
184+
}
185+
parserBuffer.execute(endBuffer)
186+
})
187+
153188
// STRINGS
154189

155190
suite.add('\nOLD CODE: + simple string', function () {
@@ -164,6 +199,10 @@ suite.add('NEW CODE: + simple string', function () {
164199
parser.execute(stringBuffer)
165200
})
166201

202+
suite.add('NEW BUF: + simple string', function () {
203+
parserBuffer.execute(stringBuffer)
204+
})
205+
167206
// INTEGERS
168207

169208
suite.add('\nOLD CODE: + integer', function () {
@@ -178,6 +217,10 @@ suite.add('NEW CODE: + integer', function () {
178217
parser.execute(integerBuffer)
179218
})
180219

220+
suite.add('NEW STR: + integer', function () {
221+
parserStr.execute(integerBuffer)
222+
})
223+
181224
// BIG INTEGER
182225

183226
suite.add('\nOLD CODE: + big integer', function () {
@@ -192,6 +235,10 @@ suite.add('NEW CODE: + big integer', function () {
192235
parser.execute(bigIntegerBuffer)
193236
})
194237

238+
suite.add('NEW STR: + big integer', function () {
239+
parserStr.execute(bigIntegerBuffer)
240+
})
241+
195242
// ARRAYS
196243

197244
suite.add('\nOLD CODE: * array', function () {
@@ -206,6 +253,10 @@ suite.add('NEW CODE: * array', function () {
206253
parser.execute(arrayBuffer)
207254
})
208255

256+
suite.add('NEW BUF: * array', function () {
257+
parserBuffer.execute(arrayBuffer)
258+
})
259+
209260
// BIG ARRAYS
210261

211262
suite.add('\nOLD CODE: * bigArray', function () {
@@ -220,6 +271,10 @@ suite.add('NEW CODE: * bigArray', function () {
220271
parser.execute(bigArrayBuffer)
221272
})
222273

274+
suite.add('NEW BUF: * bigArray', function () {
275+
parserBuffer.execute(bigArrayBuffer)
276+
})
277+
223278
// ERRORS
224279

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

0 commit comments

Comments
 (0)