Code Monkey home page Code Monkey logo

memory-stats.js's Introduction

memory-stats.js

Like stats.js but for JS memory

@jeromeetienne, inspired by mrdoob's stats.js code, wrote this as part of tquery. I've now promoted it to a standalone repo and cleaned it all up.

image

Usage:

  1. Start Chrome with --enable-precise-memory-info
    • Otherwise the results from performance.memory are bucketed and less useful.
  2. Include memory.stats.js
  3. Instantiate it (stats = new MemoryStats(), add the stats.element to the DOM, and run stats.update() regularly.

That might look something like:

    var stats = new MemoryStats();

    stats.domElement.style.position = 'fixed';
    stats.domElement.style.right        = '0px';
    stats.domElement.style.bottom       = '0px';
    
    document.body.appendChild( stats.domElement );

    requestAnimationFrame(function rAFloop(){
        stats.update();
        requestAnimationFrame(rAFloop);
    });

Run Chrome with the flag and open demo/index.html to see it in action.

Framework adaptors

Bookmarklet

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

javascript:(function(){var script=document.createElement('script');script.src='https://rawgit.com/paulirish/memory-stats.js/master/bookmarklet.js';document.head.appendChild(script);})()

memory-stats.js's People

Contributors

paulirish avatar jeromeetienne avatar tshaddix avatar jmalonzo avatar kossnocorp avatar ragingwind avatar arthurvr avatar spite avatar shprink avatar jurre avatar silentmatt avatar vigneshshanmugam avatar fay-jai avatar hemanth avatar

Watchers

James Cloos avatar Valter Barros avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.