From cefe3ab01929600af30830da7f744a51298836cf Mon Sep 17 00:00:00 2001 From: brianc Date: Thu, 30 Dec 2010 21:45:16 -0600 Subject: [PATCH] benchmarks have nicer result printing --- benchmark/simple-query-bench.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/benchmark/simple-query-bench.js b/benchmark/simple-query-bench.js index 59ff33de..46601589 100644 --- a/benchmark/simple-query-bench.js +++ b/benchmark/simple-query-bench.js @@ -3,9 +3,14 @@ var bencher = require('bencher'); var helper = require(__dirname + '/../test/test-helper') var conString = helper.connectionString() +var round = function(num) { + return Math.round((num*1000))/1000 +} + var doBenchmark = function() { var bench = bencher({ - repeat: 3000, + name: 'query compare', + repeat: 1000, actions: [{ name: 'simple query', run: function(next) { @@ -38,13 +43,16 @@ var doBenchmark = function() { }); bench(function(result) { console.log(); + console.log("%s (%d repeats):", result.name, result.repeat) result.actions.forEach(function(action) { - console.log("%s -> %d", action.name, action.meanTime); + console.log(" %s: \n average: %d ms\n total: %d ms", action.name, round(action.meanTime), round(action.totalTime)); }) client.end(); }) } + + var client = new pg.Client(conString); client.connect(); client.connection.once('readyForQuery', doBenchmark)