diff --git a/index.js b/index.js index 113d2d2..9ebfde9 100755 --- a/index.js +++ b/index.js @@ -2,24 +2,26 @@ var spawn = require('child_process').spawn; var path = require('path'); var async = require('async'); - var Bench = require('./lib/bench'); var cli = require('./lib/cli'); - var db = require('mongojs')(cli.database, [cli.collection]); - var bench = new Bench(cli.url); var runs = []; var runcount = 0; var db; function median(values) { - values.sort(function(a,b) {return (a.last_nom > b.last_nom) ? 1 : ((b.last_nom > a.last_nom) ? -1 : 0);} ); + values.sort(function(a,b) { return a.metrics.httpTrafficCompleted - b.metrics.httpTrafficCompleted;} ); var half = Math.floor(values.length/2); if (values.length % 2) { return values[half]; } - return (values[half-1] + values[half]) / 2.0; + var ret=values[half]; + var other=values[half-1].metrics; + for(i in ret.metrics ){ + ret.metrics[i]=(ret.metrics[i]+other[i])/2; + } + return ret; } function seriesAction(callback) { @@ -71,9 +73,8 @@ switch (cli.action) { for (i = 0; i < cli.runs; i++) { series.push(seriesAction); } - before(); - async.series(series, function (err, result) { + async.parallelLimit(series,cli.limit, function (err, result) { var set = median(runs); set.created_at = Date.now(); if (set) { @@ -95,4 +96,3 @@ switch (cli.action) { } }); } - diff --git a/lib/cli.js b/lib/cli.js index d4468a9..1fc423c 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -7,10 +7,11 @@ var path = require('path'); cli .version('0.0.1') .usage('[options] [url]') - .option('-d , --database [DATBASE]' , 'mongodb connection string') - .option('-t , --collection [COLLECTION]' , 'mongodb collection name (default: client)') - .option('-r , --runs [RUNS]' , '[BENCH ONLY] number of runs (defult: 9)' , parseInt) - .option('-c , --config [CONFIG]' , 'config file location'); + .option('-d , --database [DATABASE]' , 'mongodb connection string') + .option('-t , --collection [COLLECTION]' , 'mongodb collection name (default: client)') + .option('-r , --runs [RUNS]' , '[BENCH ONLY] number of runs (default: 9)' , parseInt) + .option('-l , --limit [RUNS]' , '[BENCH ONLY] number of runs (default: cpus + 1)' , parseInt) + .option('-c , --config [CONFIG]' , 'config file location'); cli .command('server') @@ -39,8 +40,8 @@ if (!cli.url) { } cli.action = cli.action || 'bench'; - cli.runs = cli.runs || 9; +cli.limit = cli.limit || require('os').cpus().length + 1; cli.database = cli.database || 'localhost/benchdb'; cli.collection = cli.collection || 'client'; diff --git a/package.json b/package.json index eeb7a1b..7b3a40a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bench", - "version": "0.1.0", + "version": "0.1.1", "description": "Benchmark a web page and display results with a pretty UI.", "main": "index.js", "scripts": { @@ -24,6 +24,7 @@ "performance" ], "author": "Joshua Mervine (http://mervine.net)", + "contributors": ["Nicholas Jones (http://nich.olas.biz)"], "license": "BSD", "bugs": { "url": "https://github.com/jmervine/bench/issues" @@ -36,7 +37,7 @@ "jade": ">= 0.0.1", "connect": "~2.8.5", "async": "~0.2.9", - "mongojs": "~0.7.17" + "mongojs": "0.10.*" }, "devDependencies": { "nodeunit": "~0.8.1" diff --git a/server/views/layout.jade b/server/views/layout.jade index f0288f0..b7c7155 100644 --- a/server/views/layout.jade +++ b/server/views/layout.jade @@ -1,4 +1,4 @@ -!!! +doctype html head title= title_text