Created
February 3, 2011 06:51
-
-
Save Constellation/809138 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bench(c, func) { | |
var d = Date.now(); | |
try { | |
func(); | |
} catch(e) { | |
print(e); | |
} | |
print(c + " : " + (Date.now() - d)); | |
} | |
bench('pure', function() { | |
var ary = []; | |
ary.length = (1 << 24) - 1; | |
ary.length = 0; | |
}); | |
bench('tainted', function() { | |
"use strict"; | |
var ary = []; | |
Object.defineProperty(ary, '0', { value: "OK" }); | |
ary.length = (1 << 24) - 1; | |
ary.length = 1; | |
// ary.length = 0; | |
}); | |
bench('tainted2', function() { | |
"use strict"; | |
var ary = []; | |
Object.defineProperty(ary, '0', { | |
enumerable: true, | |
configurable: true, | |
writable: true, | |
value: "OK" | |
}); | |
ary.length = (1 << 24) - 1; | |
ary.length = 1; | |
// ary.length = 0; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment