mirror of
https://github.com/lynchmarkHQ/lynchmark.com.git
synced 2026-10-17 17:27:53 +00:00
Docs: Update benchmark results
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
async function processCSV(csvString, config) {
|
||||
const d3 = await import('https://unpkg.com/d3?module');
|
||||
const data = d3.csvParse(csvString);
|
||||
const filtered = data.filter(row => row[config.filterColumn] == config.filterValue);
|
||||
const grouped = d3.group(filtered, d => d[config.groupBy]);
|
||||
return [...grouped].map(([key, group]) => {
|
||||
const col = config.aggregateColumn;
|
||||
const vals = group.map(r => Number(r[col]) || 0);
|
||||
let result;
|
||||
switch (config.operation) {
|
||||
case 'sum': result = vals.reduce((a, b) => a + b, 0); break;
|
||||
case 'avg': result = vals.reduce((a, b) => a + b, 0) / vals.length; break;
|
||||
case 'count': result = group.length; break;
|
||||
}
|
||||
return { [config.groupBy]: key, result };
|
||||
});
|
||||
}
|
||||
export default processCSV;
|
||||
// Generation time: 34.010s
|
||||
// Result: PASS
|
||||
Reference in New Issue
Block a user