Skip to content

Commit 7f43b2f

Browse files
committed
get the benchmarks working
1 parent cc7d99f commit 7f43b2f

13 files changed

+68
-55
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ node_modules/
44
package-lock.json
55
yarn.lock
66
dist/
7+
benchmark-results/

src/ci/performance-benchmark.ts

Lines changed: 56 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ export class PerformanceBenchmark {
162162
testData: TestData,
163163
parser: any,
164164
): Promise<BenchmarkResult> {
165-
// Similar to benchmarkLegacy but for modern implementation
166165
const memBefore = process.memoryUsage();
167166
let memPeak = memBefore;
168167

@@ -176,44 +175,45 @@ export class PerformanceBenchmark {
176175
const startTime = Date.now();
177176
let errorCount = 0;
178177

179-
try {
180-
const result = parser.parse(testData.csvContent, {
181-
header: true,
182-
dynamicTyping: true,
183-
complete: (results: any) => {
184-
// Results handling
185-
},
186-
error: () => {
187-
errorCount++;
188-
},
189-
});
190-
191-
const endTime = Date.now();
192-
clearInterval(memoryMonitor);
193-
const memAfter = process.memoryUsage();
178+
return new Promise((resolve, reject) => {
179+
try {
180+
const result = parser.parse(testData.csvContent, {
181+
header: true,
182+
dynamicTyping: true,
183+
complete: (results: any) => {
184+
const endTime = Date.now();
185+
clearInterval(memoryMonitor);
186+
const memAfter = process.memoryUsage();
194187

195-
const totalTime = endTime - startTime;
196-
const rowsPerSecond = Math.round(
197-
(testData.expectedRows / totalTime) * 1000,
198-
);
188+
const totalTime = endTime - startTime;
189+
const rowsPerSecond = Math.round(
190+
(testData.expectedRows / totalTime) * 1000,
191+
);
199192

200-
return {
201-
implementation: "modern",
202-
testName: testData.name,
203-
rowsPerSecond,
204-
totalRows: testData.expectedRows,
205-
totalTime,
206-
memoryUsage: {
207-
before: memBefore,
208-
after: memAfter,
209-
peak: memPeak,
210-
},
211-
errors: errorCount,
212-
};
213-
} catch (error) {
214-
clearInterval(memoryMonitor);
215-
throw error;
216-
}
193+
resolve({
194+
implementation: "modern",
195+
testName: testData.name,
196+
rowsPerSecond,
197+
totalRows: testData.expectedRows,
198+
totalTime,
199+
memoryUsage: {
200+
before: memBefore,
201+
after: memAfter,
202+
peak: memPeak,
203+
},
204+
errors: errorCount,
205+
});
206+
},
207+
error: (error: any) => {
208+
errorCount++;
209+
console.warn(`Modern parsing error: ${error.message}`);
210+
},
211+
});
212+
} catch (error) {
213+
clearInterval(memoryMonitor);
214+
reject(error);
215+
}
216+
});
217217
}
218218

219219
/**
@@ -345,13 +345,19 @@ export async function runCIBenchmark(): Promise<void> {
345345
try {
346346
// Import both implementations
347347
const legacyPapa = require("../../legacy/papaparse.js");
348-
const modernPapa = require("../../dist/papaparse.js");
348+
const modernPapaModule = require("../../dist/papaparse.js");
349+
const modernPapa = modernPapaModule.default || modernPapaModule;
349350

350-
console.log("📊 Running performance comparison between legacy and V6 implementations...");
351+
console.log(
352+
"📊 Running performance comparison between legacy and V6 implementations...",
353+
);
351354

352355
// Run the benchmark suite
353-
const { results, summary } = await benchmark.runBenchmarkSuite(legacyPapa, modernPapa);
354-
356+
const { results, summary } = await benchmark.runBenchmarkSuite(
357+
legacyPapa,
358+
modernPapa,
359+
);
360+
355361
// Export results for analysis
356362
benchmark.exportResults(results, `benchmark-${Date.now()}.json`);
357363

@@ -360,11 +366,17 @@ export async function runCIBenchmark(): Promise<void> {
360366
console.log(` Total Tests: ${summary.totalTests}`);
361367
console.log(` Passed: ${summary.passedTests}`);
362368
console.log(` Failed: ${summary.failedTests}`);
363-
console.log(` Average Performance Ratio: ${(summary.avgPerformanceRatio * 100).toFixed(1)}%`);
364-
console.log(` Average Memory Ratio: ${(summary.avgMemoryRatio * 100).toFixed(1)}%`);
369+
console.log(
370+
` Average Performance Ratio: ${(summary.avgPerformanceRatio * 100).toFixed(1)}%`,
371+
);
372+
console.log(
373+
` Average Memory Ratio: ${(summary.avgMemoryRatio * 100).toFixed(1)}%`,
374+
);
365375

366376
if (!summary.passed) {
367-
console.error("❌ Performance benchmarks failed - some tests did not meet thresholds");
377+
console.error(
378+
"❌ Performance benchmarks failed - some tests did not meet thresholds",
379+
);
368380
process.exit(1);
369381
}
370382

src/ci/snapshots/comments.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@
3535
}
3636
},
3737
"checksum": "0423b324abe92cf93c11d33acb1bac7b7cfb1bce204b383b323aaa274bea2851",
38-
"timestamp": "2025-07-29T07:00:38.688Z",
38+
"timestamp": "2025-07-29T07:02:58.279Z",
3939
"version": "1.0.0"
4040
}

src/ci/snapshots/custom_delimiter.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@
3838
}
3939
},
4040
"checksum": "0423b324abe92cf93c11d33acb1bac7b7cfb1bce204b383b323aaa274bea2851",
41-
"timestamp": "2025-07-29T07:00:38.688Z",
41+
"timestamp": "2025-07-29T07:02:58.280Z",
4242
"version": "1.0.0"
4343
}

src/ci/snapshots/dynamic_typing.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@
4040
}
4141
},
4242
"checksum": "0423b324abe92cf93c11d33acb1bac7b7cfb1bce204b383b323aaa274bea2851",
43-
"timestamp": "2025-07-29T07:00:38.686Z",
43+
"timestamp": "2025-07-29T07:02:58.278Z",
4444
"version": "1.0.0"
4545
}

src/ci/snapshots/edge_case_empty.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@
2626
}
2727
},
2828
"checksum": "58b959bd26bfc22602568dcd31559a1feed2c1952eead50c83bd45300b258a9a",
29-
"timestamp": "2025-07-29T07:00:38.688Z",
29+
"timestamp": "2025-07-29T07:02:58.280Z",
3030
"version": "1.0.0"
3131
}

src/ci/snapshots/empty_fields.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@
4242
}
4343
},
4444
"checksum": "4fee89ca69e645265256377f3546f0ecbf3e4ccc3e4df5304692bdec340aab0f",
45-
"timestamp": "2025-07-29T07:00:38.686Z",
45+
"timestamp": "2025-07-29T07:02:58.279Z",
4646
"version": "1.0.0"
4747
}

src/ci/snapshots/line_breaks_in_quotes.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@
3434
}
3535
},
3636
"checksum": "0423b324abe92cf93c11d33acb1bac7b7cfb1bce204b383b323aaa274bea2851",
37-
"timestamp": "2025-07-29T07:00:38.687Z",
37+
"timestamp": "2025-07-29T07:02:58.279Z",
3838
"version": "1.0.0"
3939
}

src/ci/snapshots/quoted_fields.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@
3434
}
3535
},
3636
"checksum": "0423b324abe92cf93c11d33acb1bac7b7cfb1bce204b383b323aaa274bea2851",
37-
"timestamp": "2025-07-29T07:00:38.686Z",
37+
"timestamp": "2025-07-29T07:02:58.279Z",
3838
"version": "1.0.0"
3939
}

src/ci/snapshots/simple_csv.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@
3737
}
3838
},
3939
"checksum": "0423b324abe92cf93c11d33acb1bac7b7cfb1bce204b383b323aaa274bea2851",
40-
"timestamp": "2025-07-29T07:00:38.685Z",
40+
"timestamp": "2025-07-29T07:02:58.278Z",
4141
"version": "1.0.0"
4242
}

0 commit comments

Comments
 (0)