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:
@@ -0,0 +1,22 @@
|
||||
const processCSV = async (csvString, config) => {
|
||||
const { filterColumn: key, filterValue: val, groupBy: group, aggregateColumn: target, operation: op } = config
|
||||
|
||||
const [dsv, d3] = await Promise.all([
|
||||
import('https://esm.sh/d3-dsv'),
|
||||
import('https://esm.sh/d3-array')
|
||||
])
|
||||
|
||||
const getVal = d => +d[target] || 0
|
||||
const rows = dsv.csvParse(csvString).filter(r => r[key] == val)
|
||||
|
||||
const aggs = d3.rollup(
|
||||
rows,
|
||||
v => op === 'count' ? v.length :
|
||||
op === 'sum' ? d3.sum(v, getVal) :
|
||||
d3.mean(v, getVal),
|
||||
d => d[group]
|
||||
)
|
||||
|
||||
return Array.from(aggs, ([gVal, result]) => ({ [group]: gVal, result }))
|
||||
}
|
||||
export default processCSV;
|
||||
Reference in New Issue
Block a user