LoginSignup
544
535

More than 5 years have passed since last update.

JSのパフォーマンスをお手軽に解析する方法

Last updated at Posted at 2015-09-16

TL;DR

Chromeで console.profile()console.profileEnd() を使うと超簡単にJSの実行パフォーマンスを解析できる、という事実を今日知ったのでシェアさせていただきます。

やりたいこと

JSの任意の関数の実行プロファイル (コールスタックごとの所要時間) を見たい。

やりかた

Google Chromeのデバッグコンソールで以下のようなスクリプトを入力して実行 (見やすくするため改行入れてますが実際には一行で)

console
console.profile();
xxxxx(); // 解析したい処理
console.profileEnd()

実行されると以下のようにログが出力されます。

output
Profile 'Profile 1' started.
Profile 'Profile 1' finished.

んで、Profileタブを開くと、実行プロファイルが出力されいます。

image

コールスタックごとの処理時間が分かって超便利 \(^o^)/

参照

以上です。

544
535
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
544
535