diff --git a/benchmark/js-versus-native-bench.js b/benchmark/js-versus-native-bench.js deleted file mode 100644 index b65fb98..0000000 --- a/benchmark/js-versus-native-bench.js +++ /dev/null @@ -1,68 +0,0 @@ -var pg = require(__dirname + '/../lib') -var pgNative = require(__dirname + '/../lib/native'); -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({ - name: 'js/native compare', - repeat: 1000, - actions: [{ - name: 'javascript client - simple query', - run: function(next) { - var query = client.query('SELECT name, age FROM person WHERE age > 10'); - query.on('end', function() { - next(); - }); - } - },{ - name: 'native client - simple query', - run: function(next) { - var query = nativeClient.query('SELECT name FROM person WHERE age > $1', [10]); - query.on('end', function() { - next(); - }); - } - }, { - name: 'javascript client - parameterized query', - run: function(next) { - var query = client.query('SELECT name, age FROM person WHERE age > $1', [10]); - query.on('end', function() { - next(); - }); - } - },{ - name: 'native client - parameterized query', - run: function(next) { - var query = nativeClient.query('SELECT name, age FROM person WHERE age > $1', [10]); - query.on('end', function() { - next(); - }); - } - }] - }); - bench(function(result) { - console.log(); - console.log("%s (%d repeats):", result.name, result.repeat) - result.actions.forEach(function(action) { - console.log(" %s: \n average: %d ms\n total: %d ms", action.name, round(action.meanTime), round(action.totalTime)); - }) - client.end(); - nativeClient.end(); - }) -} - -var client = new pg.Client(conString); -var nativeClient = new pgNative.Client(conString); -client.connect(); -client.on('connect', function() { - nativeClient.connect(); - nativeClient.on('connect', function() { - doBenchmark(); - }); -}); diff --git a/benchmark/large-datatset-bench.js b/benchmark/large-datatset-bench.js deleted file mode 100644 index a5e0346..0000000 --- a/benchmark/large-datatset-bench.js +++ /dev/null @@ -1,125 +0,0 @@ -var pg = require(__dirname + '/../lib') -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(cb) { - var bench = bencher({ - name: 'select large sets', - repeat: 10, - actions: [{ - name: 'selecting string', - run: function(next) { - var query = client.query('SELECT name FROM items'); - query.on('error', function(er) { - console.log(er);throw er; - }); - - query.on('end', function() { - next(); - }); - } - }, { - name: 'selecting integer', - run: function(next) { - var query = client.query('SELECT count FROM items'); - query.on('error', function(er) { - console.log(er);throw er; - }); - - query.on('end', function() { - next(); - }) - } - }, { - name: 'selecting date', - run: function(next) { - var query = client.query('SELECT created FROM items'); - query.on('error', function(er) { - console.log(er);throw er; - }); - - query.on('end', function() { - next(); - }) - } - }, { - name: 'selecting row', - run: function(next) { - var query = client.query('SELECT * FROM items'); - query.on('end', function() { - next(); - }) - } - }, { - name: 'loading all rows into memory', - run: function(next) { - var query = client.query('SELECT * FROM items', next); - } - }] - }); - bench(function(result) { - console.log(); - console.log("%s (%d repeats):", result.name, result.repeat) - result.actions.forEach(function(action) { - console.log(" %s: \n average: %d ms\n total: %d ms", action.name, round(action.meanTime), round(action.totalTime)); - }) - client.end(); - cb(); - }) -} - - -var client = new pg.Client(conString); -client.connect(); -console.log(); -console.log("creating temp table"); -client.query("CREATE TEMP TABLE items(name VARCHAR(10), created TIMESTAMPTZ, count INTEGER)"); -var count = 10000; -console.log("inserting %d rows", count); -for(var i = 0; i < count; i++) { - var query = { - name: 'insert', - text: "INSERT INTO items(name, created, count) VALUES($1, $2, $3)", - values: ["item"+i, new Date(2010, 01, 01, i, 0, 0), i] - }; - client.query(query); -} - -client.once('drain', function() { - console.log('done with insert. executing pure-javascript benchmark.'); - doBenchmark(function() { - var oldclient = client; - client = new pg.native.Client(conString); - client.on('error', function(err) { - console.log(err); - throw err; - }); - - client.connect(); - client.connect(); - console.log(); - console.log("creating temp table"); - client.query("CREATE TEMP TABLE items(name VARCHAR(10), created TIMESTAMPTZ, count INTEGER)"); - var count = 10000; - console.log("inserting %d rows", count); - for(var i = 0; i < count; i++) { - var query = { - name: 'insert', - text: "INSERT INTO items(name, created, count) VALUES($1, $2, $3)", - values: ["item"+i, new Date(2010, 01, 01, i, 0, 0), i] - }; - client.query(query); - } - client.once('drain', function() { - console.log("executing native benchmark"); - doBenchmark(function() { - console.log("all done"); - }) - }) - }); -}); diff --git a/benchmark/simple-query-bench.js b/benchmark/simple-query-bench.js deleted file mode 100644 index 4660158..0000000 --- a/benchmark/simple-query-bench.js +++ /dev/null @@ -1,58 +0,0 @@ -var pg = require(__dirname + '/../lib') -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({ - name: 'query compare', - repeat: 1000, - actions: [{ - name: 'simple query', - run: function(next) { - var query = client.query('SELECT name FROM person WHERE age > 10'); - query.on('end', function() { - next(); - }); - } - },{ - name: 'unnamed prepared statement', - run: function(next) { - var query = client.query('SELECT name FROM person WHERE age > $1', [10]); - query.on('end', function() { - next(); - }); - } - },{ - name: 'named prepared statement', - run: function(next) { - var config = { - name: 'get peeps', - text: 'SELECT name FROM person WHERE age > $1', - values: [10] - } - client.query(config).on('end', function() { - next(); - }); - } - }] - }); - bench(function(result) { - console.log(); - console.log("%s (%d repeats):", result.name, result.repeat) - result.actions.forEach(function(action) { - 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)