1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-07 13:22:56 +03:00

chore: add callback functionality back in

This also improves the performance for multi / batch commands a lot.
The reason is that now there are only callbacks internally even if
a promise is going to be returned in the end.
This commit is contained in:
Ruben Bridgewater
2017-11-29 19:16:40 -02:00
parent 2b4ab10305
commit d7c31da598
10 changed files with 288 additions and 184 deletions

View File

@@ -120,7 +120,11 @@ Test.prototype.newClient = function (id) {
}
Test.prototype.onClientsReady = function () {
process.stdout.write(`${lpad(this.args.descr, 13)}, ${this.args.batch ? lpad(`batch ${this.args.batch}`, 9) : lpad(this.args.pipeline, 9)}/${this.clientsReady} `)
process.stdout.write(
`${lpad(this.args.descr, 13)}, ` +
`${this.args.batch ? lpad(`batch ${this.args.batch}`, 9) : lpad(this.args.pipeline, 9)}/` +
`${this.clientsReady} `
)
this.testStart = Date.now()
return this.fillPipeline()
}
@@ -140,20 +144,18 @@ Test.prototype.fillPipeline = function () {
if (this.batchPipeline) {
return this.batch()
}
const promises = []
while (pipeline < this.maxPipeline) {
this.commandsSent++
pipeline++
promises.push(this.sendNext())
this.sendNext()
}
return Promise.all(promises)
}
Test.prototype.batch = function () {
const curClient = clientNr++ % this.clients.length
const start = process.hrtime()
let i = 0
const batch = this.clients[curClient].batch()
const batch = this.clients[curClient].multi()
while (i++ < this.batchPipeline) {
this.commandsSent++