fetch-text-by-line.bench.ts 654 B

123456789101112131415161718
  1. import { readFileByLine/* , readFileByLineNew */ } from './fetch-text-by-line';
  2. import path from 'node:path';
  3. import fsp from 'node:fs/promises';
  4. import { OUTPUT_SURGE_DIR } from '../constants/dir';
  5. const file = path.join(OUTPUT_SURGE_DIR, 'domainset/reject_extra.conf');
  6. (async () => {
  7. const { bench, group, run } = await import('mitata');
  8. group(() => {
  9. bench('readFileByLine', () => Array.fromAsync(readFileByLine(file)));
  10. // bench('readFileByLineNew', async () => Array.fromAsync(await readFileByLineNew(file)));
  11. bench('fsp.readFile', () => fsp.readFile(file, 'utf-8').then((content) => content.split('\n')));
  12. });
  13. run();
  14. })();