/
githubmirror
/
node
Обзор
Документация
Войти
/
githubmirror
/
node
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
benchmark/misc/util-extend-vs-object-assign.js
30 строк
707 B
Marco Ippolito
Revert "util: move util._extend to eol"
14 июн 2024, 16:07
Не верифицирован
14 июн 2024, 16:07
b5aae52
Код
Авторство
О чём код?
'use strict'; const common = require('../common.js'); const util = require('util'); const bench = common.createBenchmark(main, { type: ['extend', 'assign'], n: [10e4], }); function main({ n, type }) { let fn; if (type === 'extend') { fn = util._extend; } else if (type === 'assign') { fn = Object.assign; } // Force-optimize the method to test so that the benchmark doesn't // get disrupted by the optimizer kicking in halfway through. for (let i = 0; i < type.length * 10; i += 1) fn({}, process.env); const obj = new Proxy({}, { set: function(a, b, c) { return true; } }); bench.start(); for (let j = 0; j < n; j += 1) fn(obj, process.env); bench.end(n); }