1
0
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:
leibale
2021-12-01 20:17:52 -05:00
parent cba0289ff7
commit f55de0efbf
10 changed files with 916 additions and 8 deletions

View 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');

View 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();
}

View 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();
}

View 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();
}