You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
improve encodeCommand performance, add set-get-delete-string benchmark
This commit is contained in:
13
benchmark/lib/set-get-delete-string/index.js
Normal file
13
benchmark/lib/set-get-delete-string/index.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import yargs from 'yargs';
|
||||
import { hideBin } from 'yargs/helpers';
|
||||
import { randomBytes } from 'crypto';
|
||||
|
||||
const { size } = yargs(hideBin(process.argv))
|
||||
.option('size', {
|
||||
type: 'number',
|
||||
default: 1024,
|
||||
demandOption: true
|
||||
})
|
||||
.parseSync();
|
||||
|
||||
export const randomString = randomBytes(size).toString('ascii');
|
19
benchmark/lib/set-get-delete-string/ioredis.js
Normal file
19
benchmark/lib/set-get-delete-string/ioredis.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import Redis from 'ioredis';
|
||||
|
||||
const client = new Redis({ lazyConnect: true });
|
||||
|
||||
export function setup() {
|
||||
return client.connect();
|
||||
}
|
||||
|
||||
export function benchmark({ randomString }) {
|
||||
return Promise.all([
|
||||
client.set(randomString, randomString),
|
||||
client.get(randomString),
|
||||
client.del(randomString)
|
||||
]);
|
||||
}
|
||||
|
||||
export function teardown() {
|
||||
return client.disconnect();
|
||||
}
|
19
benchmark/lib/set-get-delete-string/local.js
Normal file
19
benchmark/lib/set-get-delete-string/local.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import { createClient } from '@node-redis/client-local';
|
||||
|
||||
const client = createClient();
|
||||
|
||||
export function setup() {
|
||||
return client.connect();
|
||||
}
|
||||
|
||||
export function benchmark({ randomString }) {
|
||||
return Promise.all([
|
||||
client.set(randomString, randomString),
|
||||
client.get(randomString),
|
||||
client.del(randomString)
|
||||
]);
|
||||
}
|
||||
|
||||
export function teardown() {
|
||||
return client.disconnect();
|
||||
}
|
19
benchmark/lib/set-get-delete-string/production.js
Normal file
19
benchmark/lib/set-get-delete-string/production.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import { createClient } from '@node-redis/client-production';
|
||||
|
||||
const client = createClient();
|
||||
|
||||
export function setup() {
|
||||
return client.connect();
|
||||
}
|
||||
|
||||
export function benchmark({ randomString }) {
|
||||
return Promise.all([
|
||||
client.set(randomString, randomString),
|
||||
client.get(randomString),
|
||||
client.del(randomString)
|
||||
]);
|
||||
}
|
||||
|
||||
export function teardown() {
|
||||
return client.disconnect();
|
||||
}
|
Reference in New Issue
Block a user