' P '

whatever I will forget

Node.js 処理時間、メモリ使用状況の確認

処理時間の確認

$ time node hoge.js

返却値:

real 0m31.394s
user    0m31.425s
sys 0m0.026s

real: 実際に処理にかかった時間.
user: 実行ユーザで処理にかかった時間.
sys: システムが他処理で使用した時間.

プロファイルツール

node --prof hoge.js
node --prof-process isolate-0x6079120-39-v8.log

isolate-から始まるlogは別途作成されたものを使用する.

[Summary] と [Bottom up (heavy) profile]

上記項目を確認する.
下記例で言えば、JavaScriptの処理、そしてhoge.jsのtest関数にて処理時間がかかっていることが把握できる.

 [Summary]:
   ticks  total  nonlib   name
  33761   85.6%   98.6%  JavaScript
      0    0.0%    0.0%  C++
     63    0.2%    0.2%  GC
   5206   13.2%          Shared libraries
    491    1.2%          Unaccounted

   ticks parent  name
  33713   85.4%  LazyCompile: *test /a/hoge.js:2:13
  33713  100.0%    LazyCompile: *test /a/hoge.js:2:13
  33713  100.0%      LazyCompile: *test /a/hoge.js:2:13
  33713  100.0%        LazyCompile: *test /a/hoge.js:2:13
  33713  100.0%          LazyCompile: *test /a/hoge.js:2:13
  33713  100.0%            LazyCompile: *test /a/hoge.js:2:13