/
githubmirror
/
node
Обзор
Документация
Войти
/
githubmirror
/
node
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
benchmark/os/hostname.js
31 строка
665 B
Aras Abbasi
os: cache homedir, remove getCheckedFunction
15 окт 2023, 09:50
Не верифицирован
15 окт 2023, 09:50
0f0dd1a
Код
Авторство
О чём код?
'use strict'; const common = require('../common.js'); const hostname = require('os').hostname; const assert = require('assert'); const bench = common.createBenchmark(main, { n: [1e6], }); function main({ n }) { // Warm up. const length = 1024; const array = []; for (let i = 0; i < length; ++i) { array.push(hostname()); } bench.start(); for (let i = 0; i < n; ++i) { const index = i % length; array[index] = hostname(); } bench.end(n); // Verify the entries to prevent dead code elimination from making // the benchmark invalid. for (let i = 0; i < length; ++i) { assert.strictEqual(typeof array[i], 'string'); } }