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,21 +1,21 @@
|
||||
const processCSV = async (csvString, config) => {
|
||||
const { parse } = await import('https://cdn.jsdelivr.net/npm/papaparse@5.4.1/+esm');
|
||||
const { filterColumn: fc, filterValue: fv, groupBy: gb, aggregateColumn: ac, operation: op } = config;
|
||||
const acc = {};
|
||||
const processCSV = async (csv, { filterColumn: fc, filterValue: fv, groupBy: gb, aggregateColumn: ac, operation: op }) => {
|
||||
const { default: Papa } = await import('https://esm.sh/papaparse@5.4.1');
|
||||
const { data } = Papa.parse(csv, { header: true, skipEmptyLines: true });
|
||||
|
||||
parse(csvString, { header: true, skipEmptyLines: true }).data.forEach(row => {
|
||||
if (row[fc] == fv) {
|
||||
const key = row[gb];
|
||||
const val = +row[ac] || 0;
|
||||
const entry = acc[key] ??= { sum: 0, count: 0 };
|
||||
entry.sum += val;
|
||||
entry.count++;
|
||||
}
|
||||
});
|
||||
const groups = data.reduce((acc, row) => {
|
||||
if (row[fc] == fv) {
|
||||
const key = row[gb];
|
||||
const val = +row[ac] || 0;
|
||||
acc[key] = acc[key] || { s: 0, c: 0 };
|
||||
acc[key].s += val;
|
||||
acc[key].c++;
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
return Object.entries(acc).map(([key, { sum, count }]) => ({
|
||||
[gb]: key,
|
||||
result: op === 'avg' ? sum / count : op === 'count' ? count : sum
|
||||
}));
|
||||
return Object.entries(groups).map(([key, { s, c }]) => ({
|
||||
[gb]: key,
|
||||
result: op === 'count' ? c : op === 'sum' ? s : s / c
|
||||
}));
|
||||
};
|
||||
export default processCSV;
|
||||
Reference in New Issue
Block a user