UNPKG

ibm_db

Version:

IBM DB2 and IBM Informix bindings for node

64 lines (52 loc) 1.39 kB
var common = require("./common") , odbc = require("../") , assert = require("assert") , db = new odbc.Database() , iterations = 100000 ; db.open(common.connectionString, function(err){ if (err) { console.error(err); process.exit(1); } issueQuery2(function () { finish(); }); }); function issueQuery2(done) { var count = 0 , time = new Date().getTime(); var stmt = db.prepareSync('select ? as test'); for (var x = 0; x < iterations; x++) { (function (x) { stmt.bind([x], function (err) { if (err) { console.log(err); return finish(); } stmt.executeNonQuery(function (err, result) { cb(err, result, x); }); }); })(x); } function cb (err, data, x) { if (err) { console.error(err); return finish(); } //TODO: there's nothing to assert in this case. //we actually need to insert data and then get //the data back out and then assert. if (++count == iterations) { var elapsed = new Date().getTime() - time; console.log("%d queries issued in %d seconds, %d/sec : Prepare - Bind - ExecuteNonQuery ", count, elapsed/1000, Math.floor(count/(elapsed/1000))); return done(); } } } function finish() { db.close(function () { console.log("connection closed"); }); }