Skip to content

Commit

Permalink
basic docker compose setup for benchmarking (sometimes fails in docke…
Browse files Browse the repository at this point in the history
…r with segfault)
  • Loading branch information
paulkarabilo committed Jan 14, 2018
1 parent 244f939 commit 83bec2a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
12 changes: 12 additions & 0 deletions benchmark/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3'
services:
addon:
build: ..
environment:
- REDIS_HOST=redis
- REDIS_PORT=6379
command: npm run bench
depends_on:
- redis
redis:
image: "redis:alpine"
21 changes: 16 additions & 5 deletions benchmark/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
var Benchmark = require('benchmark');
var nativeRedis = require('../index.js');
var addon = require('../index.js');
var jsRedis = require('redis');
var fastRedis = require('redis-fast-driver');

var nativeClient = new nativeRedis.Client();
var jsClient = jsRedis.createClient();
var fastClient = new fastRedis({});
console.log("STARTING BENCHMARK");
var nativeClient = new addon.Client({
host: process.env.HOST || 'localhost',
port: process.env.PORT || 6379
});
var jsClient = jsRedis.createClient({
host: process.env.HOST || 'localhost',
port: process.env.PORT || 6379
});
var fastClient = new fastRedis({
host: process.env.HOST || 'localhost',
port: process.env.PORT || 6379
});
var suite = new Benchmark.Suite;
var opts = {defer: true}

console.log("STARTING PING SUITE");
suite
.add('NativeRedis#Call', (def) => nativeClient.call("PING", () => def.resolve()), opts)
.add('NodeRedisAddon#Call', (def) => nativeClient.call("PING", () => def.resolve()), opts)
.add('FastRedis#Call', (def) => fastClient.rawCall(["PING"], () => def.resolve()), opts)
.add('JSRedis#Call', (def) => jsClient.send_command("PING", () => def.resolve()), opts)
.on('cycle', (event) => console.log(String(event.target)))
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"build:debug": "node-gyp build -debug",
"rebuild:debug": "node-gyp rebuild -debug",
"test": "mocha test/spec",
"test:debug": "mocha --debug test/spec"
"test:debug": "mocha --debug test/spec",
"bench": "node benchmark"
},
"author": "",
"license": "WTFPL",
Expand Down

0 comments on commit 83bec2a

Please sign in to comment.