mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-04-27 19:52:14 +00:00
Docs: Update benchmark for anthropic/claude-opus-4.7 EFF:medium
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
async function processCSV(csv, { filterColumn, filterValue, groupBy, aggregateColumn, operation }) {
|
||||
const { default: Papa } = await import('https://esm.sh/papaparse@5.4.1');
|
||||
const { data } = Papa.parse(csv, { header: true, skipEmptyLines: true });
|
||||
const groups = {};
|
||||
for (const row of data) {
|
||||
if (row[filterColumn] != filterValue) continue;
|
||||
const key = row[groupBy];
|
||||
const n = Number(row[aggregateColumn]);
|
||||
const val = Number.isFinite(n) ? n : 0;
|
||||
(groups[key] ??= { sum: 0, count: 0 });
|
||||
groups[key].sum += val;
|
||||
groups[key].count++;
|
||||
}
|
||||
const calc = {
|
||||
sum: g => g.sum,
|
||||
avg: g => g.sum / g.count,
|
||||
count: g => g.count,
|
||||
}[operation];
|
||||
return Object.entries(groups).map(([k, g]) => ({ [groupBy]: k, result: calc(g) }));
|
||||
}
|
||||
export default processCSV;
|
||||
// Generation time: 5.004s
|
||||
// Result: PASS
|
||||
Reference in New Issue
Block a user