SQLiteAnalyzer(仮)Firefox Developers Conference 2009-11-08 |
開発者募集中 |
by teramako teramako@gmail.com
ちょっと前、Firefoxのパフォーマンス改善のために内部で使用されるSQLiteデータベースの再編成が注目を浴びた
また、Firefox3.6からplaces.sqliteがアイドル時間中にVACUUMされるようになった
それはそれでいいけど、DBの中身を可視化したい。データを以って再編成時期を見極めたい
Firefox以外のアプリケーションが使用するDBにも応用できるのでは!?
sqlite.org提供のsqliteデータベースの使用状況を解析するコマンドラインツール
SQL分を抜き出して加工して、DBに保管
var filePath = "C:\\foo\\bar\\hoge.exe";
var file = Cc["@mozilla.org/file/local;1"]
.createInstance(Ci.nsILocalFile);
file.initWithPath(filePath);
var args = ["foo", "bar"];
var p = Cc["@mozilla.org/process/util;1"]
.createInstance(Ci.nsIProcess);
p.init(file);
p.run(true, args, args.length);
function RequestObserver(func, args){
this._func = func; this._args = args;
}
RequestObserver.prototype = {
QueryInterface: function (iid) {
if (!iid.equals(Ci.nsIRequestObserver) && !iid.equals(Ci.nsISupports))
throw Components.results.NS_ERROR_NO_INTERFACE;
return this;
},
onStartRequest: function (channel, ctxt) { },
onStopRequest: function (channel, ctxt, status) {
// ...
}
};
const ipcService = Cc["@mozilla.org/process/ipc-service;1"].getService(Ci.nsIIPCService);
function runAsync(file, args, cbFunc, cbArgs) {
var stdoutPipeConsole = Cc["@mozilla.org/process/pipe-console;1"].createInstance(Ci.nsIPipeConsole);
stdoutPipeConsole.open(1024, 0, true); // 1024行分
var stderrPipeConsole = Cc["@mozilla.org/process/pipe-console;1"].createInstance(Ci.nsIPipeConsole);
stderrPipeConsole.open(100, 0, true); // 100行分
var env = [];
var observer = new RequestObserver(cbFunc, cbArgs); // nsIRequestObserver
var ipcRequest = ipcService.runAsync(file, args, args.length,
"", // preInput
"", // stdInData
0, // stdInData.length
env, env.length,
stdoutPipeConsole,
stderrPipeConsole,
observer);
}
要するに何も出来て無い