mirror of
https://github.com/lynchmarkHQ/lynchmark.com.git
synced 2026-10-19 02:07:52 +00:00
Docs: Update Gemini benchmark results
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
const processCSV = async (csvStr, { filterColumn: fc, filterValue: fv, groupBy: gb, aggregateColumn: ac, operation: op }) => {
|
||||
const { csvParse } = await import('https://esm.sh/d3-dsv@3');
|
||||
|
||||
const groups = csvParse(csvStr).reduce((acc, row) => {
|
||||
if (row[fc] == fv) {
|
||||
const key = row[gb], val = +row[ac] || 0;
|
||||
const entry = acc.get(key) || { s: 0, c: 0 };
|
||||
entry.s += val;
|
||||
entry.c++;
|
||||
acc.set(key, entry);
|
||||
}
|
||||
return acc;
|
||||
}, new Map());
|
||||
const processCSV = async (csv, { filterColumn, filterValue, groupBy, aggregateColumn, operation }) => {
|
||||
const { parse } = await import('https://cdn.jsdelivr.net/npm/papaparse@5.4.1/+esm');
|
||||
const groups = {};
|
||||
|
||||
return Array.from(groups, ([key, { s, c }]) => ({
|
||||
[gb]: key,
|
||||
result: op === 'count' ? c : op === 'sum' ? s : s / c
|
||||
parse(csv, { header: true, skipEmptyLines: true }).data.forEach(row => {
|
||||
if (row[filterColumn] == filterValue) {
|
||||
const key = row[groupBy];
|
||||
const val = +row[aggregateColumn] || 0;
|
||||
const acc = groups[key] ??= { sum: 0, count: 0 };
|
||||
acc.sum += val;
|
||||
acc.count++;
|
||||
}
|
||||
});
|
||||
|
||||
return Object.entries(groups).map(([key, { sum, count }]) => ({
|
||||
[groupBy]: key,
|
||||
result: operation === 'count' ? count : operation === 'avg' ? sum / count : sum
|
||||
}));
|
||||
};
|
||||
export default processCSV;
|
||||
Reference in New Issue
Block a user