loop.js
This file
Path
benchmarks/utils/src/loop.js
37 lines · 593 bytes · JavaScript
Last changed by
Not known.
History of this fileTake it
The walk stopped after 200 commits: lines older than f0b094d point at it.
Merge commit from forkYusuke Wadabefore adoptionf0b094d
lines 1–37why, one step back1import { run, group, bench } from 'mitata'23const arr = new Array(100000).fill(Math.random())45bench('noop', () => {})67group('loop', () => {8 bench('map', () => {9 const newArr = []10 arr.map((e) => {11 newArr.push(e)12 })13 })1415 bench('forEach', () => {16 const newArr = []17 arr.forEach((e) => {18 newArr.push(e)19 })20 })2122 bench('for of', () => {23 const newArr = []24 for (const e of arr) {25 newArr.push(e)26 }27 })2829 bench('for', () => {30 const newArr = []31 for (let i = 0; i < arr.length; i++) {32 newArr.push(arr[i])33 }34 })35})3637run()