0.10.5 • Published 4 years ago

js-perf-visualizer v0.10.5

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

JS Perf Visualizer

Easy to understand JavaScrip Performance Visualization tool to understand when and why your UI becomes unresponsive or your animation is lagging.

npm.io

Install

npm install --save-dev js-perf-visualizer

Use

Add it to your index.html

<script src="node_modules/js-perf-visualizer/build-es5/JsPerfVisualizer.js"></script>
<script>
  window.jsPerfVisualizer = new JsPerfVisualizer.default();
</script>

or add it to your index.js

import JsPerfVisualizer from 'js-perf-visualizer';
... 
const jsPerfVisualizer = new JsPerfVisualizer();
...

Graph

Graph makes it obvious when exactly and how much your UI becomes unresponsive or your animation starts lagging.

npm.io

Start/Stop Marks

Use jsPerfVisualizer.mark.start('some mark text'); and jsPerfVisualizer.mark.stop('some mark text'); to fin the source of your lagging by starting to break it up and measure the parts. Indentation suggest that a mark was triggered why an other was still running.
Note: If you would like to see your mark in the report, pass in true as second argument, e.g.: jsPerfVisualizer.mark.start('mark text in report', ture);

npm.io

Options

You can pass in options at instantiation. E.g.:

const jsPerfVisualizer = new JsPerfVisualizer({
  fpsTarget:            60,
  fpsWarningLevel:      30,
  isAutoStart:          true,
  isMinimizedByDefault: false,
});
Available Option
OPTIONDESCRIPTION
fpsTargetEven if your app has a higher frame rate, JS P. V. won't measure it, otherwise it starts impacting performance.
fpsWarningLevelIf JS performance drops below this number you will get a warning in Logs tab and you can start dig in using jsPerfVisualizer.mark.start('...');
isAutoStartBlock JS P. V. from starting automatically by setting this option to false. When any page loads there a bunch of activity that is outside of your control - e.g. Chrome Extension loading, Engine parsing loaded scripts - that impacts performance but you might not want to include it in your perf report. Use JsPerfVisualizer.start() when you app start to kick it off manually.
isMinimizedByDefaultUse JS P. V. only when you need it by pressing Ctrl+i and let it run in the background when you don't.

Report

Get a report on the most important performance characteristics, low FPS, and the marks you use to measure specific parts of your application, e.g: img hashing. Note: If you would like to see your mark in the report, pass in true as second argument, e.g.: jsPerfVisualizer.mark.start('mark text in report', ture);

npm.io

CLI Integration

Run a performance test as part of your build/deploy and generate a report as JSON for further analysis by calling jsPerfVisualizer.genReport()

{ "averageFps":     57,
  "laggingLongest": 1509.33,
  "lowFps": {
    "average":  10,
    "lowest":   1,
    "noDrop":   8
  },
  "listMark":[
    {
      "type": "mark",
      "ctr":  1,
      "idEvtLoopStart": 0,
      "idEvtLoopStop":  146,
      "timestampStart": 1566353303579,
      "timeFromInit":   4528,
      "timestampStop":  1566353308103,
      "duration":       4524,
      "text":           "mark 2",
      "indentLevel":    0,
      "isPartOfReport": true
    }
  ]
}

or call jsPerfVisualizer.genReportAsString() for a human readable format.

* ************************* *
* JS PERF VISUALIZER REPORT *
* ************************* *

GENERAL INFO
> Average FPS : 57
> Longest Lagg: 1509.33

FPS IN LOW RANGE
> Average FPS: 10
> Lowest FPS : 1
> No Drops   : 8

MARKS
> Duration: 4524ms "mark 2"
> Duration: 1523ms "mark 3"
> Duration:    0ms "mark 1"

Tips and Tricks

Use #showJsPerfVisualizer in the URL to bring up the UI if you cant press Ctrl + I on your keyboard from some reason. E.g.: http://mySite.com/#showJsPerfVisualizer

0.10.5

4 years ago

0.9.2

5 years ago

0.8.0

5 years ago

0.7.4

5 years ago

0.7.3

5 years ago

0.7.2

5 years ago

0.7.1

5 years ago

0.7.0

5 years ago

0.6.0

5 years ago

0.5.0

5 years ago

0.4.3

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago