]> git.ardis.lu - csvio/commitdiff
Use consistent name length to make it easier to compare outputs
authorArdis Lu <ardisglu@gmail.com>
Fri, 14 Feb 2025 07:39:37 +0000 (23:39 -0800)
committerArdis Lu <ardisglu@gmail.com>
Fri, 14 Feb 2025 07:39:37 +0000 (23:39 -0800)
benchmark/core.bench.js

index 2e658fd54ba81655d5d2ccebb85266fb23b6cb57..1d46ed229a576803e23f8246f175fcf5eacbe225 100644 (file)
@@ -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) { }
 });
This page took 0.047624 seconds and 4 git commands to generate.