Skip to content

Commit

Permalink
refactor(benchmark): update suites
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmlnc committed Jun 12, 2019
1 parent c1d686c commit 0ba6dc0
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 23 deletions.
7 changes: 3 additions & 4 deletions src/benchmark/suites/async/fast-glob-current.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import * as path from 'path';

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

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

const timeStart = utils.timeStart();

glob(process.env.BENCHMARK_PATTERN as string, settings)
glob(process.env.BENCHMARK_PATTERN as string, options)
.then((matches) => {
const memory = utils.getMemory();
const time = utils.timeEnd(timeStart);
Expand Down
4 changes: 1 addition & 3 deletions src/benchmark/suites/async/node-glob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import glob = require('glob');

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

import { IOptions } from 'glob';

const options: IOptions = {
const options: glob.IOptions = {
cwd: path.join(process.cwd(), process.env.BENCHMARK_BASE_DIR as string),
nosort: true,
nounique: true,
Expand Down
14 changes: 7 additions & 7 deletions src/benchmark/suites/stream/fast-glob-current.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import * as path from 'path';

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

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

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

const timeStart = utils.timeStart();

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

stream.once('error', () => process.exit(0));
stream.on('data', (entry) => entries.add(entry));
stream.on('data', (entry: string) => entries.push(entry));
stream.once('end', () => {
const memory = utils.getMemory();
const time = utils.timeEnd(timeStart);
Expand Down
4 changes: 2 additions & 2 deletions src/benchmark/suites/stream/fast-glob-previous.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ const options: fg.Options = {
unique: false
};

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

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.on('data', (entry: string) => entries.push(entry));
stream.once('end', () => {
const memory = utils.getMemory();
const time = utils.timeEnd(timeStart);
Expand Down
7 changes: 3 additions & 4 deletions src/benchmark/suites/sync/fast-glob-current.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import * as path from 'path';

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

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

const timeStart = utils.timeStart();

try {
const matches = glob.sync(process.env.BENCHMARK_PATTERN as string, settings);
const matches = glob.sync(process.env.BENCHMARK_PATTERN as string, options);
const memory = utils.getMemory();
const time = utils.timeEnd(timeStart);
const measures = utils.getMeasures(matches.length, time, memory);
Expand Down
4 changes: 1 addition & 3 deletions src/benchmark/suites/sync/node-glob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import glob = require('glob');

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

import { IOptions } from 'glob';

const options: IOptions = {
const options: glob.IOptions = {
cwd: path.join(process.cwd(), process.env.BENCHMARK_BASE_DIR as string),
nosort: true,
nounique: true,
Expand Down

0 comments on commit 0ba6dc0

Please sign in to comment.