/
githubmirror
/
node
Обзор
Документация
Войти
/
githubmirror
/
node
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
benchmark/timers/timers-insert-unpooled.js
32 строки
647 B
Antoine du Hamel
benchmark: add trailing commas
29 янв 2023, 21:13
Не верифицирован
29 янв 2023, 21:13
ca5f322
Код
Авторство
О чём код?
'use strict'; const common = require('../common.js'); const assert = require('assert'); const bench = common.createBenchmark(main, { n: [1e6], direction: ['start', 'end'], }); function main({ direction, n }) { const timersList = []; bench.start(); if (direction === 'start') { for (let i = 1; i <= n; i++) { timersList.push(setTimeout(cb, i)); } } else { for (let i = n; i > 0; i--) { timersList.push(setTimeout(cb, i)); } } bench.end(n); for (let j = 0; j < n; j++) { clearTimeout(timersList[j]); } } function cb() { assert.fail(`Timer ${this._idleTimeout} should not call callback`); }