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:
@@ -1,2 +1,17 @@
|
||||
async function processCSV(csv,{filterColumn:f,filterValue:v,groupBy:g,aggregateColumn:a,operation:o}){const{default:P}=await import('https://cdn.jsdelivr.net/npm/papaparse@5.4.1/+esm');const{data}=P.parse(csv,{header:true});const grouped=data.filter(r=>r[f]==v).reduce((c,r)=>{const k=r[g],n=Number(r[a])||0;c[k]||=(c[k]={s:0,c:0});c[k].s+=n;c[k].c++;return c},{});return Object.entries(grouped).map(([k,{s,c}])=>({[g]:k,result:o=='sum'?s:o=='avg'?s/c:c}))}
|
||||
export default processCSV;
|
||||
async function processCSV(csv, { filterColumn: fc, filterValue: fv, groupBy: gb, aggregateColumn: ac, operation: op }) {
|
||||
const { default: Papa } = await import('https://cdn.jsdelivr.net/npm/papaparse@5.4.1/+esm');
|
||||
const groups = {};
|
||||
|
||||
Papa.parse(csv, { header: true }).data
|
||||
.filter(r => r[fc] == fv)
|
||||
.forEach(r => {
|
||||
const key = r[gb], g = groups[key] || (groups[key] = { c: 0, s: 0 });
|
||||
g.c++;
|
||||
g.s += +r[ac] || 0;
|
||||
});
|
||||
|
||||
return Object.entries(groups).map(([k, { c, s }]) => ({ [gb]: k, result: op === 'count' ? c : op === 'avg' ? s / c : s }));
|
||||
}
|
||||
export default processCSV;
|
||||
// Generation time: 66.769s
|
||||
// Result: PASS
|
||||
Reference in New Issue
Block a user