A utility script to provide an average FPS value based on CSS transitions
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md
fpsmeter.js

README.md

#fpsmeter.js A script to evaluate the framerate of an animation embedded in a web page using CSS transitions.

Please refer to this blog post for an explaination of how it works: Effectively measuring browser framerate using CSS

##Usage

<script type='text/javascript' src='fpsmeter.js'></script>
...
<script type='text/javascript'>

if(!window.FPSMeter){
    alert("This test page doesn't seem to include FPSMeter: aborting"); 
    return;
}

var results = document.getElementById("results");

// Register a progress call-back
document.addEventListener('fps',
    function(evt) {
        results.innerHTML = "Current framerate: " + evt.fps + " fps";
    },
    false);

// Start FPS analysis, optionnally specifying the rate at which FPS 
// are evaluated (in seconds, defaults to 1).
FPSMeter.run();

// Do your stuff here
....

// Stop FPS analysis
FPSMeter.stop();

</script>

##Demo

Try out the demo.

##License

You may use this code under the terms of the MIT license.