From 0ba6dc0f961526e96e2298125c928b21ed2813ab Mon Sep 17 00:00:00 2001 From: mrmlnc Date: Wed, 12 Jun 2019 22:52:20 +0300 Subject: [PATCH] refactor(benchmark): update suites --- src/benchmark/suites/async/fast-glob-current.ts | 7 +++---- src/benchmark/suites/async/node-glob.ts | 4 +--- src/benchmark/suites/stream/fast-glob-current.ts | 14 +++++++------- src/benchmark/suites/stream/fast-glob-previous.ts | 4 ++-- src/benchmark/suites/sync/fast-glob-current.ts | 7 +++---- src/benchmark/suites/sync/node-glob.ts | 4 +--- 6 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/benchmark/suites/async/fast-glob-current.ts b/src/benchmark/suites/async/fast-glob-current.ts index 7913d498..29ecd162 100644 --- a/src/benchmark/suites/async/fast-glob-current.ts +++ b/src/benchmark/suites/async/fast-glob-current.ts @@ -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); diff --git a/src/benchmark/suites/async/node-glob.ts b/src/benchmark/suites/async/node-glob.ts index 94ed266d..20acdea0 100644 --- a/src/benchmark/suites/async/node-glob.ts +++ b/src/benchmark/suites/async/node-glob.ts @@ -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, diff --git a/src/benchmark/suites/stream/fast-glob-current.ts b/src/benchmark/suites/stream/fast-glob-current.ts index 46ff9744..f3621c81 100644 --- a/src/benchmark/suites/stream/fast-glob-current.ts +++ b/src/benchmark/suites/stream/fast-glob-current.ts @@ -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 = 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); diff --git a/src/benchmark/suites/stream/fast-glob-previous.ts b/src/benchmark/suites/stream/fast-glob-previous.ts index 4471fed3..bced115a 100644 --- a/src/benchmark/suites/stream/fast-glob-previous.ts +++ b/src/benchmark/suites/stream/fast-glob-previous.ts @@ -9,14 +9,14 @@ const options: fg.Options = { unique: false }; -const entries: Set = 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); diff --git a/src/benchmark/suites/sync/fast-glob-current.ts b/src/benchmark/suites/sync/fast-glob-current.ts index c0c2c5f2..0a8078b6 100644 --- a/src/benchmark/suites/sync/fast-glob-current.ts +++ b/src/benchmark/suites/sync/fast-glob-current.ts @@ -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); diff --git a/src/benchmark/suites/sync/node-glob.ts b/src/benchmark/suites/sync/node-glob.ts index 0ced372b..5869d0c8 100644 --- a/src/benchmark/suites/sync/node-glob.ts +++ b/src/benchmark/suites/sync/node-glob.ts @@ -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,