Skip to content

Instantly share code, notes, and snippets.

@wolfeidau
Last active December 17, 2015 00:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wolfeidau/5524680 to your computer and use it in GitHub Desktop.
Save wolfeidau/5524680 to your computer and use it in GitHub Desktop.
Using node profiler util programs

#Introduction

So you have a program that is doing bad things and have isolated that to a test case, this guides you though using one of the tools bundled with node-profiler to read the v8 logs.

  • Install node-profiler into your project directory.
npm install profiler --from-git git://github.com/wolfeidau/node-profiler.git#updated_v8_to_3.14.5.8
  • Build the tools.
cd node_modules/profiler/tools
./build-nprof
cd -
  • Run your test.
node --prof lev
node_modules/profiler/nprof
  • Some sample output.
Statistical profiling result from v8.log, (67 ticks, 2 unaccounted, 0 excluded).

 [Unknown]:
   ticks  total  nonlib   name
      2    3.0%

 [Shared libraries]:
   ticks  total  nonlib   name
     51   76.1%    0.0%  /usr/local/bin/node
      8   11.9%    0.0%  /usr/lib/system/libsystem_c.dylib
      4    6.0%    0.0%  /usr/lib/system/libsystem_kernel.dylib

 [JavaScript]:
   ticks  total  nonlib   name
      1    1.5%   25.0%  LazyCompile: ~fs.closeSync fs.js:396
      1    1.5%   25.0%  LazyCompile: ~exec native regexp.js:168
      1    1.5%   25.0%  LazyCompile: ~defineProperties native v8natives.js:1102
      1    1.5%   25.0%  LazyCompile: ~Module._resolveFilename module.js:323

 [C++]:
   ticks  total  nonlib   name

 [GC]:
   ticks  total  nonlib   name
      2    3.0%

 [Bottom up (heavy) profile]:
  Note: percentage shows a share of a particular caller in the total
  amount of its parent calls.
  Callers occupying less than 2.0% are not shown.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment