v8-cpu-analysis

1.3.7 • Public • Published

中文版

npm version Package Quality license

v8-analytics/v8-cpu-analysis

Analysis the cpu & heap-memory log file which created by v8-profiler & heapdump,it can:

  • show you functions which are optimized failed by v8 engine
  • show you functions which exectime greater than your expected
  • show you suspicious memory leak point

Why Two Names?

v8-analytics is completely equivalent to v8-cpu-analysis, there is no difference between them.

Beacuse I want to introduce v8 engine's heap-memory analytics, so I think cpu in package name is not suitable. More, to be compatible with before, I chose them published comletely equivalent.

Installation

For Global

$ npm install v8-analytics -g

or

$ npm install v8-cpu-analysis -g

For Embedded JS code

$ npm install v8-analytics

or

$ npm install v8-cpu-analysis

Test

if you install -g, try:

//test bailout
$ va test bailout
$ va test bailout --only
//test timeout
$ va test timeout
$ va test timeout 200
$ va test timeout 200 --only
$ va test leak

va test bailout --only can list you all functions which are deoptimized, and it's deoptimization reason.

va test timeout 200 --only can list you all function which exectime > 200ms.

va test leak cans list you suspicious leak point in your project.

Quick Start

You can use this at the command line or embedded in your js code

I. Command Line

Find Function Bailout Reason

The xxx.cpu.json file created by v8-profiler:

$ va bailout xxx.cpu.json

This will list all Function, and turn the deoptimized function to red. You can also use like that:

$ va bailout xxx.cpu.json --only

This will only list the deoptimized functions.

Find Funtion Exectime Greater Than Expected

$ va timeout xxx.cpu.json

This will list all Function, and their exectime

$ va timeout xxx.cpu.json 200

This will list all Function ,and turn the functions which exectime > 200ms to red.

$ va timeout xxx.cpu.json 200 --only

This will only list the functions which exectime > 200ms.

Find suspicious memory leak point

$ va leak xxx.mem.json

This will show you suspicous leak ponit in your node.js project.

II. Embedded JS Code

'use strict';
const fs = require('fs');
const v8Analytics = require('v8-analytics');
//or you can use following, they're equival
//const v8Analytics = require('v8-cpu-analysis');
 
//list all js function and it's execTime
const json = JSON.parse(fs.readFileSync('./test.cpu.json'));
const str = v8Analytics(json);
console.log(str);
 
//list you heap memory info
const json = JSON.parse(fs.readFileSync('./test.mem.json'));
const {leakPoint, heapMap, statistics} = analysisLib.memAnalytics(allData)

Package Sidebar

Install

npm i v8-cpu-analysis

Weekly Downloads

1

Version

1.3.7

License

ISC

Last publish

Collaborators

  • hyj1991