12

プログラムで次のことを実行できるようにするいくつかのクロムAPI(クロム拡張で使用される)を探しています:--プロファイリングを開始します-プロファイリングを終了します-ページ上のすべてのJSにかかった時間のリストを取得します

私はFirefoxで次のように同じことを達成できます:

jsd = DebuggerService.getService(jsdIDebuggerService)
// start the profiling as
jsd.flags |= COLLECT_PROFILE_DATA;

// stop the profilinf as
jsd.flags &= ~COLLECT_PROFILE_DATA;

// get the details of how much time each JS function took
jsd.enumerateScripts({enumerateScript: function(script)
{
// script object has timings detail
}

開発者ツールバーからプロファイリング情報をエクスポートできる API も役立ちます

4

1 に答える 1

12

次のコードを使用して、プログラムで Google Chrome のスクリプトをプロファイリングできます。

console.profile("MyProfile");
// Enter name of script here
console.profileEnd();

「MyProfile」は、作成されるプロファイルの名前です。

ソース:

http://blog.codestars.eu/2011/profiling-with-webkit/

console.time()との組み合わせを使用して、関数/コード スニペットの実行時間を取得できます。console.timeEnd()

于 2012-08-12T17:10:14.973 に答える