summaryrefslogtreecommitdiff
path: root/deps/node/benchmark/fs/bench-mkdirp.js
blob: b9e62045f6cf50387bd75f17aeba2385206bf36e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'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));
}