/
githubmirror
/
node
Обзор
Документация
Войти
/
githubmirror
/
node
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v20.20.1
benchmark/zlib/creation.js
31 строка
696 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 zlib = require('zlib'); const bench = common.createBenchmark(main, { type: [ 'Deflate', 'DeflateRaw', 'Inflate', 'InflateRaw', 'Gzip', 'Gunzip', 'Unzip', 'BrotliCompress', 'BrotliDecompress', ], options: ['true', 'false'], n: [5e5], }); function main({ n, type, options }) { const fn = zlib[`create${type}`]; if (typeof fn !== 'function') throw new Error('Invalid zlib type'); if (options === 'true') { const opts = {}; bench.start(); for (let i = 0; i < n; ++i) fn(opts); bench.end(n); } else { bench.start(); for (let i = 0; i < n; ++i) fn(); bench.end(n); } }