mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-03-17 11:21:00 +00:00
Docs: Update benchmark for openai/gpt-5.4
This commit is contained in:
42
tests/6_csv_processor/outputs/openai_gpt-5.4.js
Normal file
42
tests/6_csv_processor/outputs/openai_gpt-5.4.js
Normal file
@@ -0,0 +1,42 @@
|
||||
export async function processCSV(csv, config) {
|
||||
const [{ default: Papa }, _] = await Promise.all([
|
||||
import('https://cdn.jsdelivr.net/npm/papaparse@5.4.1/+esm'),
|
||||
import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.min.js')
|
||||
])
|
||||
|
||||
const {
|
||||
filterColumn,
|
||||
filterValue,
|
||||
groupBy,
|
||||
aggregateColumn,
|
||||
operation
|
||||
} = config || {}
|
||||
|
||||
const { data } = Papa.parse(csv, {
|
||||
header: true,
|
||||
skipEmptyLines: true,
|
||||
transformHeader: v => String(v).trim()
|
||||
})
|
||||
|
||||
const toNum = v => {
|
||||
const n = Number(v)
|
||||
return Number.isNaN(n) ? 0 : n
|
||||
}
|
||||
|
||||
const filtered = data.filter(row => row?.[filterColumn] == filterValue)
|
||||
const groups = _.groupBy(filtered, row => row?.[groupBy])
|
||||
|
||||
return Object.entries(groups).map(([key, rows]) => {
|
||||
const count = rows.length
|
||||
const sum = rows.reduce((a, row) => a + toNum(row?.[aggregateColumn]), 0)
|
||||
const result =
|
||||
operation === 'count' ? count :
|
||||
operation === 'avg' ? (count ? sum / count : 0) :
|
||||
sum
|
||||
|
||||
return { [groupBy]: key, result }
|
||||
})
|
||||
}
|
||||
export default processCSV;
|
||||
// Generation time: 3.573s
|
||||
// Result: PASS
|
||||
Reference in New Issue
Block a user