const hirestime = require('hirestime'); | |
const Redis = require('ioredis'); | |
const stats = require('stats-lite'); | |
const client = new Redis('redis://redis:6379'); | |
const MAX_CARDINALITY = 1e6; | |
const times = []; | |
const timesGet = []; | |
const loopIterations = 1e4; | |
const KEY = `key_${Math.floor(Math.random() * 100000)}`; | |
async function execute() { | |
for (let i = 0; i < loopIterations; i++) { | |
const value = Math.floor(Math.random() * MAX_CARDINALITY); | |
const getElapsed = hirestime(); | |
await client.pfadd(KEY, value); | |
times.push(getElapsed(hirestime.MS)); | |
} | |
console.log(stats.mean(times)); | |
console.log(stats.median(times)); | |
for (let i = 0; i < loopIterations; i++) { | |
const getElapsed = hirestime(); | |
a = await client.pfcount(KEY); | |
timesGet.push(getElapsed(hirestime.MS)); | |
} | |
console.log(stats.mean(timesGet)); | |
console.log(stats.median(timesGet)); | |
} | |
execute(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment