mirror of
https://github.com/lynchmarkHQ/lynchmark.com.git
synced 2026-10-08 21:35:23 +00:00
Docs: Update benchmark results
This commit is contained in:
@@ -1,27 +1,28 @@
|
||||
const processCSV = async (csv, { filterColumn, filterValue, groupBy, aggregateColumn, operation }) => {
|
||||
const [{ default: Papa }] = await Promise.all([
|
||||
import('https://cdn.jsdelivr.net/npm/papaparse@5.4.1/+esm')
|
||||
]);
|
||||
|
||||
const { data } = Papa.parse(csv, { header: true, skipEmptyLines: true });
|
||||
async function processCSV(csv, config) {
|
||||
const { parse } = await import('https://cdn.jsdelivr.net/npm/papaparse@5.4.1/+esm');
|
||||
|
||||
const filtered = data.filter(row => row[filterColumn] == filterValue);
|
||||
const { data } = parse(csv, { header: true, skipEmptyLines: true });
|
||||
|
||||
const filtered = data.filter(row => row[config.filterColumn] == config.filterValue);
|
||||
|
||||
const groups = filtered.reduce((acc, row) => {
|
||||
const key = row[groupBy];
|
||||
if (!acc[key]) acc[key] = [];
|
||||
acc[key].push(row);
|
||||
const key = row[config.groupBy];
|
||||
(acc[key] ??= []).push(row);
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
|
||||
return Object.entries(groups).map(([key, rows]) => {
|
||||
const values = rows.map(r => Number(r[aggregateColumn]) || 0);
|
||||
const values = rows.map(r => Number(r[config.aggregateColumn]) || 0);
|
||||
const sum = values.reduce((a, b) => a + b, 0);
|
||||
|
||||
return {
|
||||
[groupBy]: key,
|
||||
result: operation === 'sum' ? sum : operation === 'avg' ? sum / values.length : values.length
|
||||
[config.groupBy]: key,
|
||||
result: config.operation === 'sum' ? sum :
|
||||
config.operation === 'avg' ? sum / values.length :
|
||||
values.length
|
||||
};
|
||||
});
|
||||
};
|
||||
export default processCSV;
|
||||
}
|
||||
export default processCSV;
|
||||
// Generation time: 4.238s
|
||||
// Result: FAIL
|
||||
Reference in New Issue
Block a user