mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-29 01:51:52 +08:00
Perf: read most of files in one pass
This commit is contained in:
17
Build/lib/fetch-text-by-line.bench.ts
Normal file
17
Build/lib/fetch-text-by-line.bench.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { bench, group, run } from 'mitata';
|
||||
import { processLine, processLineFromReadline } from './process-line';
|
||||
import { readFileByLine } from './fetch-text-by-line';
|
||||
import path from 'path';
|
||||
import fsp from 'fs/promises';
|
||||
|
||||
const file = path.resolve(import.meta.dir, '../../Source/domainset/cdn.conf');
|
||||
|
||||
group('read file by line', () => {
|
||||
bench('readline', () => processLineFromReadline(readFileByLine(file)));
|
||||
|
||||
bench('fsp.readFile', () => fsp.readFile(file, 'utf-8').then((content) => content.split('\n').filter(processLine)));
|
||||
|
||||
bench('Bun.file', () => Bun.file(file).text().then((content) => content.split('\n').filter(processLine)));
|
||||
});
|
||||
|
||||
run();
|
||||
Reference in New Issue
Block a user