public
Created

Simple profiler

  • Download Gist
profiler.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
var profiler = {
layer: $('<div id="profiler" style="position: fixed; left: 0; bottom: 0; width: 200px; z-index: 25000;"></div>'),
cache: {},
init: function(){
this.__inited = true;
$('body').mousemove(function(e) {
if(e.pageX < 200)
{
profiler.layer.css({
left: e.pageX - 200
});
}
});
this.layer.appendTo('body');
},
time: function(id){
this.cache[id] = new Date();
},
timeEnd: function(id){
if(this.__inited) $('<p>' + id + ': <b>' + ((new Date()) - this.cache[id]) + '</b></p>').appendTo(this.layer);
}
};

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.