Skip to content

Instantly share code, notes, and snippets.

@koonuf
Last active May 19, 2016 15:46
Show Gist options
  • Save koonuf/c018655c5e551aa345a9a2e18f4d6866 to your computer and use it in GitHub Desktop.
Save koonuf/c018655c5e551aa345a9a2e18f4d6866 to your computer and use it in GitHub Desktop.
var redis = require("redis"),
client = redis.createClient();
testZremForSetLength(5, () => {
testZremForSetLength(120, () => {
testZremForSetLength(1000, () => {
testZremForSetLength(10000, () => {
process.exit(0);
});
});
});
});
function testZremForSetLength(setLength, callback) {
var start = process.hrtime();
client.eval("redis.call(\"DEL\", \"test-key\");local i = 1;while (i<" + setLength + ") do redis.call(\"ZADD\", \"test-key\", i, i); i=i+1; end;local m = 1;while (m<100000) do redis.call(\"ZSCORE\", \"test-key\", \"n\"); m=m+1; end;", 0, 0, function () {
var end = process.hrtime(start);
console.info("Execution time for set length of %d: %ds %dms", setLength, end[0], end[1]/1000000);
callback();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment