diff --git a/package.json b/package.json index aa216634..0e213741 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "eslint-config-mrmlnc": "^1.1.0", "execa": "^2.0.4", "fast-glob": "^3.0.4", + "fdir": "^5.1.0", "glob": "^7.1.4", "is-ci": "^2.0.0", "log-update": "^4.0.0", diff --git a/src/benchmark/suites/product/async/fdir.ts b/src/benchmark/suites/product/async/fdir.ts new file mode 100644 index 00000000..23160d5b --- /dev/null +++ b/src/benchmark/suites/product/async/fdir.ts @@ -0,0 +1,26 @@ +import * as path from 'path'; + +import { fdir as GlobBuilder, PathsOutput } from 'fdir'; + +import * as utils from '../../../utils'; + +const CWD = path.join(process.cwd(), process.env.BENCHMARK_BASE_DIR as string); +const PATTERN = process.env.BENCHMARK_PATTERN as string; + +const fdir = new GlobBuilder() + .glob(PATTERN) + .crawl(CWD); + +const timeStart = utils.timeStart(); + +fdir.withPromise() + .then((matches) => { + const memory = utils.getMemory(); + const time = utils.timeEnd(timeStart); + const measures = utils.formatMeasures((matches as PathsOutput).length, time, memory); + + console.info(measures); + }) + .catch(() => { + process.exit(0); + }); diff --git a/src/benchmark/suites/product/sync/fdir.ts b/src/benchmark/suites/product/sync/fdir.ts new file mode 100644 index 00000000..46b0c804 --- /dev/null +++ b/src/benchmark/suites/product/sync/fdir.ts @@ -0,0 +1,25 @@ +import * as path from 'path'; + +import { fdir as GlobBuilder, PathsOutput } from 'fdir'; + +import * as utils from '../../../utils'; + +const CWD = path.join(process.cwd(), process.env.BENCHMARK_BASE_DIR as string); +const PATTERN = process.env.BENCHMARK_PATTERN as string; + +const glob = new GlobBuilder() + .glob(PATTERN) + .crawl(CWD); + +const timeStart = utils.timeStart(); + +try { + const matches = glob.sync() as PathsOutput; + const memory = utils.getMemory(); + const time = utils.timeEnd(timeStart); + const measures = utils.formatMeasures(matches.length, time, memory); + + console.info(measures); +} catch { + process.exit(0); +}