Skip to content

Instantly share code, notes, and snippets.

@bga
Created July 21, 2010 16:47
Show Gist options
  • Save bga/484744 to your computer and use it in GitHub Desktop.
Save bga/484744 to your computer and use it in GitHub Desktop.
if(!console)
console = {};
if(!console.log)
console.log = $jb._log;
console.time = $jb._timerBegin;
console.timeEnd = $jb._timerEnd;
var i, n = 3000000;
console.time("1");
i = n; while(i--)
{
a = b = 10;
}
console.timeEnd("1");
console.time("2");
(function()
{
var a, b;
(function()
{
var i = n; while(i--)
{
a = b = 10;
}
})();
})();
console.timeEnd("2");
console.time("3");
(function()
{
var a, b;
var i = n; while(i--)
{
a = b = 10;
}
})();
console.timeEnd("3");
/*
ff 3.6
1: 10955ms
2: 1917ms
3: 644ms
chrome 4
1: 10198
2: 78
3: 59
ie n/=10
1: 641
2: 321
3: 120
opera 10.52
1: 5742
2: 310
3: 52
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment