Hello,

Not sure if I should be asking on the node.js repo, thought since it was a 
built in, must be related here. Array iteration using it's iterator seems 
to be about 17% slower than indexed access. Not sure if it's to do with 
this particular benchmark, I used an array with 10k elements. Here's my 
source code,

import b from 'benny'

const testData = Array.from({ length: 10_000 }, () => new Object())

let x, y, z

b.suite(
'iteration',
b.add('for i', () => {
  for (let i = 0; i < testData.length; i++) {
    x = testData[i]
   }
}),

b.add('for of', () => {
  for (let testDatum of testData) {
    y = testDatum
  }
}),

b.add('for each', () => {
  testData.forEach((value, index) => {
    z = value
  })
}),

b.cycle(),
b.complete(),
b.save({ file: 'array-iteration', version: '1.0.0' }),
b.save({ file: 'array-iteration', format: 'chart.html' }),
)

-- 
-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- 
You received this message because you are subscribed to the Google Groups 
"v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-dev/eb8a173a-9ef6-49ef-82af-b7887c904645n%40googlegroups.com.

Reply via email to