Показать сообщение отдельно
  #2 (permalink)  
Старый 05.08.2019, 22:45
Аватар для SuperZen
Профессор
Отправить личное сообщение для SuperZen Посмотреть профиль Найти все сообщения от SuperZen
 
Регистрация: 08.11.2017
Сообщений: 641

const obj = (function (size, iterations, tests) {
  console.log('BREAK THE MYTH ;p')
  const array = Array.from({ length: size })
  const iterator = Array.from({ length: iterations })
  const score = iterator.map(iter => tests.map(test => {
    const start = performance.now()
    test(array)
    const end = performance.now()
    return [start, end]
  })).reduce((acc, result) => {
    result.forEach(row => {
      row.forEach((r, i) => {
        acc[i] += r
      })
    })
    return acc
  }, Array(tests.length).fill(0))
  console.log(`size: ${size}, iterations ${iterations}`)
  score.map((s, i) => console.log(`tests[${i}] : ${s}`))
})(
  100000,
  10,
  [
    array => array.map((item, i) => `${i}myth`),
    array => array.map((item, i) => i + 'myth'),
  ],
)


ну получается magic quotes продуктивнее ) в моем браузере...
Ответить с цитированием