Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added the ability to benchmark other commands

  • Loading branch information...
commit 5457374308c9bacf4ae9120682460ac1dc3ccb4c 1 parent 0f23037
TJ Holowaychuk authored
Showing with 21 additions and 9 deletions.
  1. +21 −9 bench.js
30 bench.js
View
@@ -24,15 +24,27 @@ var seconds = 5
// or $ nedis-server
if ('child' == args[0]) {
- var db = redis.createClient();
+ var db = redis.createClient()
+ , fn;
- (function next(){
- ++ops;
- db.set('foo', 'bar', next);
- })();
+ switch (args[1] || 'set') {
+ case 'set':
+ fn = function(){
+ ++ops;
+ db.set('foo', 'bar', fn);
+ };
+ break;
+ case 'get':
+ db.set('foo', 'bar');
+ fn = function(){
+ ++ops;
+ db.get('foo', fn);
+ };
+ }
+ fn();
} else {
- var child = spawn('node', [__filename, 'child']);
+ var child = spawn('node', [__filename, 'child'].concat(args));
child.stdout.setEncoding('ascii');
child.stdout.on('data', console.log);
@@ -45,9 +57,9 @@ if ('child' == args[0]) {
process.on('SIGQUIT', function(){
console.log();
- console.log('seconds : %d', seconds);
- console.log('operations : %d', ops);
- console.log('ops / second : %d', ops / seconds);
+ console.log(' seconds : %d', seconds);
+ console.log(' operations : %d', ops);
+ console.log(' ops / second : %d', ops / seconds);
console.log();
process.exit();
});
Please sign in to comment.
Something went wrong with that request. Please try again.