Skip to content

saadehmad/stats.js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stats.js

JavaScript Performance Monitor

This class provides a simple info box that will help you monitor your code performance.

  • FPS Frames rendered in the last second. The higher the number the better.
  • MS Milliseconds needed to render a frame. The lower the number the better.
  • MB MBytes of allocated memory. (Run Chrome with --enable-precise-memory-info)

Screenshots

fps.png ms.png mb.png

Usage

var stats = new Stats();
stats.setMode( 1 ); // 0: fps, 1: ms, 2: mb

// align top-left
stats.domElement.style.position = 'absolute';
stats.domElement.style.left = '0px';
stats.domElement.style.top = '0px';

document.body.appendChild( stats.domElement );

var update = function () {

	stats.begin();

	// monitored code goes here

	stats.end();

	requestAnimationFrame( update );

};

requestAnimationFrame( update );

Bookmarklet

You can add this code to any page using the following bookmarklet:

javascript:(function(){var script=document.createElement('script');script.onload=function(){var stats=new Stats();stats.domElement.style.cssText='position:fixed;left:0;top:0;z-index:10000';document.body.appendChild(stats.domElement);requestAnimationFrame(function loop(){stats.update();requestAnimationFrame(loop)});};script.src='//rawgit.com/mrdoob/stats.js/master/build/stats.min.js';document.head.appendChild(script);})()

About

JavaScript Performance Monitor

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HTML 62.9%
  • JavaScript 34.1%
  • Python 3.0%