-
-
Save kangax/c36ea485926806020024 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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" | |
"http://www.w3.org/TR/html4/strict.dtd"> | |
<html> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | |
<title></title> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
(function(){ | |
var o1 = { | |
o2: { | |
o3: { | |
o41: 1, | |
o42: false | |
} | |
} | |
}; | |
function testWith() { | |
with (o1.o2.o3) { | |
o41; | |
o42; | |
} | |
} | |
function testFullPropAccess() { | |
o1.o2.o3.o41 | |
o1.o2.o3.o42; | |
} | |
function testAliasedPropAccess() { | |
var o = o1.o2.o3; | |
o.o41; | |
o.o42; | |
} | |
var lim = 500000; | |
var t = new Date(); | |
for (var i=lim; i--; ) { | |
testWith(); | |
} | |
var t1 = new Date() - t; | |
t = new Date(); | |
for (var i=lim; i--; ) { | |
testFullPropAccess(); | |
} | |
var t2 = new Date() - t; | |
t = new Date(); | |
for (var i=lim; i--; ) { | |
testAliasedPropAccess(); | |
} | |
var t3 = new Date() - t; | |
document.write('t1: ' + t1 + 'ms<br>t2: ' + t2 + 'ms<br>t3: ' + t3 + 'ms'); | |
})(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment