Commit db452fdd by Orlando Vazquez

speed wip

parent 44c8c30d
...@@ -92,9 +92,10 @@ Database.prototype.executeQuery = function(sql, bindings, queryCallback) { ...@@ -92,9 +92,10 @@ Database.prototype.executeQuery = function(sql, bindings, queryCallback) {
} }
statement.finalize(function () { statement.finalize(function () {
self.currentQuery = undefined;
queryCallback(undefined, rows);
// if there are any queries queued, let them know it's safe to go // if there are any queries queued, let them know it's safe to go
self.db.emit("ready"); self.db.emit("ready");
queryCallback(undefined, rows);
}); });
} }
......
...@@ -6,16 +6,68 @@ var sqlite = require("./sqlite"); ...@@ -6,16 +6,68 @@ var sqlite = require("./sqlite");
var db = new sqlite.Database(); var db = new sqlite.Database();
db.open("mydatabase.db", function () { // db.open("mydatabase.db", function () {
puts("opened the db"); // puts("opened the db");
db.query("SELECT * FROM foo WHERE baz < ? AND baz > ?", [6, 3], function (error, result) { // db.query("SELECT * FROM foo WHERE baz < ? AND baz > ?", [6, 3], function (error, result) {
ok(!error);
puts("query callback " + inspect(result));
equal(result.length, 2);
});
// db.query("SELECT 1", function (error, result) {
// ok(!error); // ok(!error);
// puts("query callback " + inspect(result)); // puts("query callback " + inspect(result));
// equal(result.length, 1); // equal(result.length, 2);
// }); // });
// // db.query("SELECT 1", function (error, result) {
// // ok(!error);
// // puts("query callback " + inspect(result));
// // equal(result.length, 1);
// // });
// });
fs.unlink("speedtest.db", function () {
db.open("speedtest.db", function () {
puts(inspect(arguments));
puts("open cb");
function readTest() {
var t0 = new Date;
var count = i = 100;
var rows = 0;
var innerFunc = function () {
if (!i--) {
var d = ((new Date)-t0)/1000;
puts("**** " + count + " selects in " + d + "s (" + (count/d) + "/s) "+rows+" rows total ("+(rows/d)+" rows/s)");
return;
}
if (!(i%(count/10))) {
puts("--- " + i );
}
db.query("SELECT * FROM t1", function(error, results) {
rows = rows + results.length;
process.nextTick(innerFunc);
});
};
innerFunc();
}
db.query("CREATE TABLE t1 (alpha INTEGER)", function () {
puts("create table callback" + inspect(arguments));
var t0 = new Date;
var count = i = 10000;
var innerFunc = function () {
if(!i--) {
var d = ((new Date)-t0)/1000;
puts("**** " + count + " insertions in " + d + "s (" + (count/d) + "/s)");
process.nextTick(readTest);
return;
};
if (!(i%(count/10))) {
puts("--- " + i );
}
db.query("INSERT INTO t1 VALUES (?);", [1], function() {
process.nextTick(innerFunc);
});
};
innerFunc();
});
});
}); });
...@@ -11,6 +11,7 @@ def configure(conf): ...@@ -11,6 +11,7 @@ def configure(conf):
def build(bld): def build(bld):
obj = bld.new_task_gen("cxx", "shlib", "node_addon") obj = bld.new_task_gen("cxx", "shlib", "node_addon")
obj.cxxflags = "-g"
obj.target = "sqlite3_bindings" obj.target = "sqlite3_bindings"
obj.source = "sqlite3_bindings.cc" obj.source = "sqlite3_bindings.cc"
obj.lib = "sqlite3" obj.lib = "sqlite3"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment