mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-14 08:37:56 +00:00
Docs: Update benchmark for minimax/minimax-m2.1
This commit is contained in:
33
tests/6_csv_processor/outputs/minimax_minimax-m2.1.js
Normal file
33
tests/6_csv_processor/outputs/minimax_minimax-m2.1.js
Normal file
@@ -0,0 +1,33 @@
|
||||
export async function processCSV(csvData, config) {
|
||||
const { Papa } = await import('https://cdn.skypack.dev/papaparse@5.3.2');
|
||||
const { filterColumn, filterValue, groupBy, aggregateColumn, operation } = config;
|
||||
|
||||
const { data } = Papa.parse(csvData, { header: true, skipEmptyLines: true });
|
||||
|
||||
const groups = data.reduce((acc, row) => {
|
||||
if (row[filterColumn] != filterValue) return acc;
|
||||
const key = row[groupBy];
|
||||
if (!acc[key]) acc[key] = [];
|
||||
acc[key].push(row);
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
return Object.entries(groups).map(([key, rows]) => {
|
||||
let result;
|
||||
if (operation === 'count') {
|
||||
result = rows.length;
|
||||
} else {
|
||||
const values = rows.map(r => parseFloat(r[aggregateColumn]) || 0);
|
||||
if (operation === 'sum') {
|
||||
result = values.reduce((a, b) => a + b, 0);
|
||||
} else if (operation === 'avg') {
|
||||
const sum = values.reduce((a, b) => a + b, 0);
|
||||
result = sum / values.length;
|
||||
}
|
||||
}
|
||||
return { [groupBy]: key, result };
|
||||
});
|
||||
}
|
||||
export default processCSV;
|
||||
// Generation time: 4.238s
|
||||
// Result: FAIL
|
||||
Reference in New Issue
Block a user