0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-22 07:37:56 +01:00
nodejs/benchmark/util/parse-env.js
Aviv Keller 53cba82e55
benchmark: add dotenv benchmark
PR-URL: https://github.com/nodejs/node/pull/54278
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2024-09-18 00:30:39 +00:00

24 lines
524 B
JavaScript

'use strict';
const { createBenchmark } = require('../common.js');
const path = require('node:path');
const fs = require('node:fs');
const util = require('node:util');
const assert = require('node:assert');
const bench = createBenchmark(main, {
n: 3e4,
});
const env = fs.readFileSync(path.resolve(__dirname, '../fixtures/valid.env'), 'utf-8');
function main({ n }) {
let noDead;
bench.start();
for (let i = 0; i < n; i++) {
noDead = util.parseEnv(env);
}
bench.end(n);
assert(noDead !== undefined);
}