forked from brianc/node-pg-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
91 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
var Client = require('../'); | ||
var async = require('async'); | ||
|
||
var loop = function() { | ||
var client = new Client(); | ||
|
||
var connect = function(cb) { | ||
client.connect(cb); | ||
}; | ||
|
||
var simpleQuery = function(cb) { | ||
client.query('SELECT NOW()', cb); | ||
}; | ||
|
||
var paramsQuery = function(cb) { | ||
client.query('SELECT $1::text as name', ['Brian'], cb); | ||
}; | ||
|
||
var prepared = function(cb) { | ||
client.prepare('test', 'SELECT $1::text as name', 1, function(err) { | ||
if(err) return cb(err); | ||
client.execute('test', ['Brian'], cb); | ||
}); | ||
}; | ||
|
||
var error = function(cb) { | ||
client.query('SELECT ASLKJDASLKJD', function() { | ||
cb(); | ||
}); | ||
}; | ||
|
||
var sync = function(cb) { | ||
client.querySync('SELECT NOW()'); | ||
client.querySync('SELECT $1::text as name', ['Brian']); | ||
client.prepareSync('boom', 'SELECT $1::text as name', 1); | ||
client.executeSync('boom', ['Brian']); | ||
setImmediate(cb); | ||
}; | ||
|
||
var end = function(cb) { | ||
client.end(cb); | ||
}; | ||
|
||
var ops = [ | ||
connect, | ||
simpleQuery, | ||
paramsQuery, | ||
prepared, | ||
sync, | ||
end | ||
]; | ||
|
||
var start = Date.now(); | ||
async.series(ops, function(err) { | ||
if(err) throw err; | ||
console.log(Date.now() - start); | ||
setImmediate(loop); | ||
}); | ||
}; | ||
|
||
//on my machine this will consume memory up to about 50 megs of ram | ||
//and then stabalize at that point | ||
loop(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters