mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-03-17 03:11:01 +00:00
Docs: Update benchmark for google/gemini-3.1-flash-lite-preview
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
async function processCSV(csv, { filterColumn, filterValue, groupBy, aggregateColumn, operation }) {
|
||||
const { parse } = await import('https://cdn.skypack.dev/papaparse');
|
||||
const { data: rows } = parse(csv, { header: true, dynamicTyping: true });
|
||||
|
||||
const filtered = rows.filter(r => r[filterColumn] == filterValue);
|
||||
const groups = filtered.reduce((acc, row) => {
|
||||
const key = row[groupBy];
|
||||
acc[key] = acc[key] || [];
|
||||
acc[key].push(Number(row[aggregateColumn]) || 0);
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
return Object.entries(groups).map(([key, vals]) => {
|
||||
let res;
|
||||
if (operation === 'sum') res = vals.reduce((a, b) => a + b, 0);
|
||||
if (operation === 'count') res = vals.length;
|
||||
if (operation === 'avg') res = vals.reduce((a, b) => a + b, 0) / vals.length;
|
||||
return { [groupBy]: key, result: res };
|
||||
});
|
||||
}
|
||||
export default processCSV;
|
||||
// Generation time: 1.399s
|
||||
// Result: PASS
|
||||
Reference in New Issue
Block a user