Skip to content

Commit

Permalink
build(benchmark): add suite for stream API
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmlnc committed Jun 12, 2019
1 parent 40a1096 commit d64c24f
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,14 @@
"smoke": "mocha \"out/**/*.smoke.js\" -s 0",
"build": "npm run clean && npm run compile && npm run lint && npm test",
"watch": "npm run clean && npm run compile -- --sourceMap --watch",
"bench": "npm run bench-async && npm run bench-sync",
"bench": "npm run bench-async && npm run bench-stream && npm run bench-sync",
"bench-async": "npm run bench-async-flatten && npm run bench-async-deep",
"bench-stream": "npm run bench-stream-flatten && npm run bench-stream-deep",
"bench-sync": "npm run bench-sync-flatten && npm run bench-sync-deep",
"bench-async-flatten": "node ./out/benchmark --type async --pattern \"*\"",
"bench-async-deep": "node ./out/benchmark --type async --pattern \"**\"",
"bench-stream-flatten": "node ./out/benchmark --type stream --pattern \"*\"",
"bench-stream-deep": "node ./out/benchmark --type stream --pattern \"**\"",
"bench-sync-flatten": "node ./out/benchmark --type sync --pattern \"*\"",
"bench-sync-deep": "node ./out/benchmark --type sync --pattern \"**\""
}
Expand Down
26 changes: 26 additions & 0 deletions src/benchmark/suites/stream/fast-glob-current.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as path from 'path';

import * as glob from '../../../index';
import Settings from '../../../settings';
import * as utils from '../../utils';

const settings = new Settings({
cwd: path.join(process.cwd(), process.env.BENCHMARK_BASE_DIR as string),
unique: false
});

const entries: Set<string> = new Set();

const timeStart = utils.timeStart();

const stream = glob.stream(process.env.BENCHMARK_PATTERN as string, settings);

stream.once('error', () => process.exit(0));
stream.on('data', (entry) => entries.add(entry));
stream.once('end', () => {
const memory = utils.getMemory();
const time = utils.timeEnd(timeStart);
const measures = utils.getMeasures(Array.from(entries).length, time, memory);

console.info(measures);
});
26 changes: 26 additions & 0 deletions src/benchmark/suites/stream/fast-glob-previous.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as path from 'path';

import fg = require('fast-glob');

import * as utils from '../../utils';

const options: fg.Options = {
cwd: path.join(process.cwd(), process.env.BENCHMARK_BASE_DIR as string),
unique: false
};

const entries: Set<string> = new Set();

const timeStart = utils.timeStart();

const stream = fg.stream(process.env.BENCHMARK_PATTERN as string, options);

stream.once('error', () => process.exit(0));
stream.on('data', (entry) => entries.add(entry));
stream.once('end', () => {
const memory = utils.getMemory();
const time = utils.timeEnd(timeStart);
const measures = utils.getMeasures(Array.from(entries).length, time, memory);

console.info(measures);
});

0 comments on commit d64c24f

Please sign in to comment.