You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
源码(对象第一个属性不同):
var obj = {a: 1, b: 2, c: 3, d: 4, e: 5, '-': 6};
var objN = {1: 1, b: 2, c: 3, d: 4, e: 5, '-': 6};
suite
.add('for .. in ..:', function () {
for (var k in obj) {
obj[k]
}
})
.add('for .. in N :', function () {
for (var k in objN) {
obj[k]
}
})
.on('cycle', function(event) {
console.log(String(event.target));
})
.on('complete', function() {
console.log('Fastest is ' + this.filter('fastest').map('name'));
})
// run async
.run({ 'async': true });
结果:
for .. in ..: x 12,439,181 ops/sec ±5.58% (75 runs sampled)
for .. in N : x 870,694 ops/sec ±6.75% (70 runs sampled)
Fastest is for .. in ..:
为什么用数字作为key,效率会这么低呢
The text was updated successfully, but these errors were encountered:
源码(对象第一个属性不同):
var obj = {a: 1, b: 2, c: 3, d: 4, e: 5, '-': 6};
var objN = {1: 1, b: 2, c: 3, d: 4, e: 5, '-': 6};
suite
.add('for .. in ..:', function () {
for (var k in obj) {
obj[k]
}
})
.add('for .. in N :', function () {
for (var k in objN) {
obj[k]
}
})
.on('cycle', function(event) {
console.log(String(event.target));
})
.on('complete', function() {
console.log('Fastest is ' + this.filter('fastest').map('name'));
})
// run async
.run({ 'async': true });
结果:
for .. in ..: x 12,439,181 ops/sec ±5.58% (75 runs sampled)
for .. in N : x 870,694 ops/sec ±6.75% (70 runs sampled)
Fastest is for .. in ..:
为什么用数字作为key,效率会这么低呢
源码(对象第一个属性不同):
var obj = {a: 1, b: 2, c: 3, d: 4, e: 5, '-': 6};
var objN = {1: 1, b: 2, c: 3, d: 4, e: 5, '-': 6};
suite
.add('for .. in ..:', function () {
for (var k in obj) {
obj[k]
}
})
.add('for .. in N :', function () {
for (var k in objN) {
obj[k]
}
})
.on('cycle', function(event) {
console.log(String(event.target));
})
.on('complete', function() {
console.log('Fastest is ' + this.filter('fastest').map('name'));
})
// run async
.run({ 'async': true });
结果:
for .. in ..: x 12,439,181 ops/sec ±5.58% (75 runs sampled)
for .. in N : x 870,694 ops/sec ±6.75% (70 runs sampled)
Fastest is for .. in ..:
为什么用数字作为key,效率会这么低呢
The text was updated successfully, but these errors were encountered: