benchmarks have nicer result printing
This commit is contained in:
parent
3ae435ca74
commit
cefe3ab019
@ -3,9 +3,14 @@ var bencher = require('bencher');
|
|||||||
var helper = require(__dirname + '/../test/test-helper')
|
var helper = require(__dirname + '/../test/test-helper')
|
||||||
var conString = helper.connectionString()
|
var conString = helper.connectionString()
|
||||||
|
|
||||||
|
var round = function(num) {
|
||||||
|
return Math.round((num*1000))/1000
|
||||||
|
}
|
||||||
|
|
||||||
var doBenchmark = function() {
|
var doBenchmark = function() {
|
||||||
var bench = bencher({
|
var bench = bencher({
|
||||||
repeat: 3000,
|
name: 'query compare',
|
||||||
|
repeat: 1000,
|
||||||
actions: [{
|
actions: [{
|
||||||
name: 'simple query',
|
name: 'simple query',
|
||||||
run: function(next) {
|
run: function(next) {
|
||||||
@ -38,13 +43,16 @@ var doBenchmark = function() {
|
|||||||
});
|
});
|
||||||
bench(function(result) {
|
bench(function(result) {
|
||||||
console.log();
|
console.log();
|
||||||
|
console.log("%s (%d repeats):", result.name, result.repeat)
|
||||||
result.actions.forEach(function(action) {
|
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();
|
client.end();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var client = new pg.Client(conString);
|
var client = new pg.Client(conString);
|
||||||
client.connect();
|
client.connect();
|
||||||
client.connection.once('readyForQuery', doBenchmark)
|
client.connection.once('readyForQuery', doBenchmark)
|
||||||
|
Loading…
Reference in New Issue
Block a user