From: Ardis Lu Date: Fri, 14 Feb 2025 07:39:37 +0000 (-0800) Subject: Use consistent name length to make it easier to compare outputs X-Git-Tag: v0.1.0~55 X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=fe32f497bfd03faaa65e501b1e9f72940d38de12;p=csvio Use consistent name length to make it easier to compare outputs --- diff --git a/benchmark/core.bench.js b/benchmark/core.bench.js index 2e658fd..1d46ed2 100644 --- a/benchmark/core.bench.js +++ b/benchmark/core.bench.js @@ -4,35 +4,37 @@ import { benchmark, benchmarkIterations } from './utils.js'; import { CSVReader, CSVTransformer, CSVWriter } from '../src/index.js'; import { createRandomCSV, createTempFile } from '../test/utils.js'; +const NAME_LENGTH = 15; + const temp = await createTempFile(); process.on('exit', () => unlinkSync(temp)); let iter = 0; -await benchmarkIterations('Write 1MB', 20, async () => { +await benchmarkIterations('Write 1MB'.padEnd(NAME_LENGTH, '.'), 20, async () => { await createRandomCSV(1000, 100, iter++).pipeTo(new CSVWriter(temp)); }); -await benchmarkIterations('Read 1MB', 20, async () => { +await benchmarkIterations('Read 1MB'.padEnd(NAME_LENGTH, '.'), 20, async () => { const r = new CSVReader(temp); for await (const _ of r) { } }); iter = 0 -await benchmarkIterations('Transform 1MB', 20, async () => { +await benchmarkIterations('Transform 1MB'.padEnd(NAME_LENGTH, '.'), 20, async () => { const r = createRandomCSV(1000, 100, iter++).pipeThrough(new CSVTransformer(r => r.map(f => Number(f) + 1))); for await (const _ of r) { } }); -await benchmark('Write 100MB', async () => { +await benchmark('Write 100MB'.padEnd(NAME_LENGTH, '.'), async () => { await createRandomCSV(100000, 100, 2).pipeTo(new CSVWriter(temp)); }); -await benchmark('Read 100MB', async () => { +await benchmark('Read 100MB'.padEnd(NAME_LENGTH, '.'), async () => { const r = new CSVReader(temp); for await (const _ of r) { } }); -await benchmark('Transform 100MB', async () => { +await benchmark('Transform 100MB'.padEnd(NAME_LENGTH, '.'), async () => { const r = createRandomCSV(100000, 100, 2).pipeThrough(new CSVTransformer(r => r.map(f => Number(f) + 1))); for await (const _ of r) { } });