Skip to content

Commit

Permalink
Merge pull request #322 from mrmlnc/TRIVIAL_fdir_benchmark
Browse files Browse the repository at this point in the history
TRIVIAL: add fdir to product benchmark
  • Loading branch information
mrmlnc committed Jun 26, 2021
2 parents 9bcc78f + d046b51 commit 6257af0
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,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",
Expand Down
26 changes: 26 additions & 0 deletions src/benchmark/suites/product/async/fdir.ts
Original file line number Diff line number Diff line change
@@ -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);
});
25 changes: 25 additions & 0 deletions src/benchmark/suites/product/sync/fdir.ts
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 6257af0

Please sign in to comment.