mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-06-28 04:12:13 +00:00
Docs: Update benchmark for moonshotai/kimi-k2.7-code
This commit is contained in:
36
tests/6_csv_processor/outputs/moonshotai_kimi-k2.7-code.js
Normal file
36
tests/6_csv_processor/outputs/moonshotai_kimi-k2.7-code.js
Normal file
@@ -0,0 +1,36 @@
|
||||
const processCSV = async (csv, {
|
||||
filterColumn: f,
|
||||
filterValue: v,
|
||||
groupBy: g,
|
||||
aggregateColumn: a,
|
||||
operation: o
|
||||
}) => {
|
||||
const [{ default: P }, { groupBy: G }] = 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/+esm')
|
||||
]);
|
||||
|
||||
const N = x => {
|
||||
const y = Number(x);
|
||||
return Number.isFinite(y) ? y : 0;
|
||||
};
|
||||
|
||||
const rows = P.parse(csv, { header: true, skipEmptyLines: true }).data;
|
||||
const groups = G(rows.filter(r => r[f] == v), r => r[g]);
|
||||
|
||||
return Object.entries(groups).map(([k, list]) => {
|
||||
let result = 0;
|
||||
|
||||
if (o === 'count') {
|
||||
result = list.length;
|
||||
} else {
|
||||
const total = list.reduce((s, r) => s + N(r[a]), 0);
|
||||
result = o === 'avg' ? total / list.length : total;
|
||||
}
|
||||
|
||||
return { [g]: k, result };
|
||||
});
|
||||
};
|
||||
export default processCSV;
|
||||
// Generation time: 38.066s
|
||||
// Result: PASS
|
||||
Reference in New Issue
Block a user