array forEach, for of vs set forEach, for of (v2)

Revision 2 of this benchmark created on


Setup

const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
const set = new Set(arr)

Test runner

Ready to run.

Testing in
TestOps/sec
set forEach
let i = 0

set.forEach(val => {
	i += val
})
ready
set for of
let i = 0

for (const val of set) {
	i += val
}
ready
array forEach
let i = 0

arr.forEach(val => {
	i += val
})
ready
array for of
let i = 0

for (const val of arr) {
	i += val
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.