Skip to content

Instantly share code, notes, and snippets.

@gfcarvalho
Forked from BKcore/perfnow.js
Created March 12, 2014 03:50
Show Gist options
  • Save gfcarvalho/9500540 to your computer and use it in GitHub Desktop.
Save gfcarvalho/9500540 to your computer and use it in GitHub Desktop.
(function(w){
var perfNow;
var perfNowNames = ['now', 'webkitNow', 'msNow', 'mozNow'];
if(!!w['performance']) for(var i = 0; i < perfNowNames.length; ++i)
{
var n = perfNowNames[i];
if(!!w['performance'][n])
{
perfNow = function(){return w['performance'][n]()};
break;
}
}
if(!perfNow)
{
perfNow = Date.now;
}
w.perfNow = perfNow;
})(window);
// Usage
console.log(window.perfNow());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment