mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 01:00:34 +08:00
18 lines
658 B
TypeScript
18 lines
658 B
TypeScript
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();
|