Skip to content

Instantly share code, notes, and snippets.

@mraleph
Created February 27, 2011 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mraleph/846213 to your computer and use it in GitHub Desktop.
Save mraleph/846213 to your computer and use it in GitHub Desktop.
String.prototype.a = function () { };
function foo () {
var a = "a";
String.prototype.a = function () { };
for (var i = 0; i < 1e7; i++) {
a.a();
}
}
function bar () {
var a = "a";
String.prototype.a = function () { };
for (var i = 0; i < 1e7; i++) {
new String(a).a();
}
}
function baz () {
var a = new String("a");
for (var i = 0; i < 1e7; i++) {
a.a();
}
}
function m (f) {
var s = Date.now();
f();
print(Date.now() - s);
}
m(foo);
m(bar);
m(baz);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment