-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(benchmark): add suite for stream API
- Loading branch information
Showing
3 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |