0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/benchmark/fs/bench-mkdirp.js
Klaus Meinhardt 6b170f7c15
benchmark: fix bench-mkdirp to use recursive option
The original PR didn't update the benchmark after renaming the option.

PR-URL: https://github.com/nodejs/node/pull/23699
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-10-28 15:09:41 +01:00

24 lines
503 B
JavaScript

'use strict';
const common = require('../common');
const fs = require('fs');
const tmpdir = require('../../test/common/tmpdir');
tmpdir.refresh();
let dirc = 0;
const bench = common.createBenchmark(main, {
n: [1e4],
});
function main({ n }) {
bench.start();
(function r(cntr) {
if (cntr-- <= 0)
return bench.end(n);
const pathname = `${tmpdir.path}/${++dirc}/${++dirc}/${++dirc}/${++dirc}`;
fs.mkdir(pathname, { recursive: true }, (err) => {
r(cntr);
});
}(n));
}