perf-loops-native.js revision 160dc8e953e71d6ef7fedc3d518b63ffa62328ca
name : 'Native',
suite : 'Loop Constructs',
version: '2010-05-28',
tests: {
"Object enumeration (exclude prototype)": {
iterations: 20,
setup: function () {
var i = 10000,
while (i--) {
testObject['key_' + i] = i;
}
},
test: function () {
for (key in testObject) {
// The first two checks here could be done outside the loop,
// but then there's a potential for failure if the object or
// the hasOwnProperty method are modified during the loop.
// Simple arithmetic operation just to prevent an
// optimizing JS engine from skipping over the empty
// loop.
}
}
}
},
"Object enumeration (include prototype)": {
iterations: 20,
setup: function () {
var i = 10000,
while (i--) {
testObject['key_' + i] = i;
}
},
test: function () {
for (key in testObject) {
// Simple arithmetic operation just to prevent an optimizing
// JS engine from skipping over the empty loop.
}
}
}
}
});