/
githubmirror
/
node
Обзор
Документация
Войти
/
githubmirror
/
node
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
benchmark/test_runner/global-sequential-tests.js
46 строк
919 B
Raz Luvaton
benchmark: add benchmarks for the test_runner
29 июл 2023, 21:07
Не верифицирован
29 июл 2023, 21:07
f458e5b
Код
Авторство
О чём код?
'use strict'; const common = require('../common'); const { it } = require('node:test'); const bench = common.createBenchmark(main, { n: [100, 1000, 1e4], type: ['sync', 'async'], }, { // We don't want to test the reporter here flags: ['--test-reporter=./benchmark/fixtures/empty-test-reporter.js'], }); async function run(n, type) { // eslint-disable-next-line no-unused-vars let avoidV8Optimization; const promises = new Array(n); switch (type) { case 'sync': { for (let i = 0; i < n; i++) { await it(`${i}`, () => { avoidV8Optimization = i; }); } break; } case 'async': for (let i = 0; i < n; i++) { await it(`${i}`, async () => { avoidV8Optimization = i; }); } break; } await Promise.all(promises); } function main({ n }) { bench.start(); run(n).then(() => { bench.end(n); }); }