Docs: Update benchmark for z-ai/glm-5

This commit is contained in:
github-actions[bot]
2026-02-12 00:32:22 +00:00
parent bff6d5226e
commit 91aa46a299
12 changed files with 216 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
async function hashPassword(password, salt) {
const scrypt = (await import('https://unpkg.com/scrypt-js')).default;
const t = new TextEncoder;
const h = await scrypt(t.encode(password), t.encode(salt), 1024, 8, 1, 32);
return [...h].map(b => b.toString(16).padStart(2, '0')).join('');
}
export default hashPassword;
// Generation time: 47.029s
// Result: FAIL

View File

@@ -0,0 +1,10 @@
async function analyzeGPS(readings, boundary) {
const turf = await import('https://esm.sh/@turf/turf');
const valid = readings.filter(r =>
turf.booleanPointInPolygon(turf.point(r.loc), boundary, {ignoreBoundary: true})
).sort((a, b) => a.ts - b.ts);
return valid.length < 2 ? 0 : Math.round(turf.length(turf.lineString(valid.map(v => v.loc))) * 100) / 100;
}
export default analyzeGPS;
// Generation time: 97.874s
// Result: PASS

View File

@@ -0,0 +1,36 @@
async function computeMST(tomlStr) {
const [{ parse }, { Heap }, { default: table }] = await Promise.all([
import('https://cdn.jsdelivr.net/npm/smol-toml/+esm'),
import('https://cdn.jsdelivr.net/npm/mnemonist/+esm'),
import('https://cdn.jsdelivr.net/npm/text-table/+esm')
]);
const { edges } = parse(tomlStr);
const heap = new Heap((a, b) => a.weight - b.weight);
edges.forEach(e => heap.push(e));
const p = new Map, r = new Map;
const find = x => p.get(x) === x ? x : p.set(x, find(p.get(x))).get(x);
const mk = n => p.has(n) || (p.set(n, n) && r.set(n, 0));
const mst = [];
let totalWeight = 0;
while (heap.size) {
const { from, to, weight } = heap.pop();
mk(from); mk(to);
let [x, y] = [find(from), find(to)];
if (x !== y) {
if (r.get(x) < r.get(y)) [x, y] = [y, x];
p.set(y, x);
if (r.get(x) === r.get(y)) r.set(x, r.get(x) + 1);
mst.push([from, to, String(weight)]);
totalWeight += weight;
}
}
return { table: table([['From', 'To', 'Weight'], ...mst]), totalWeight };
}
export default computeMST;
// Generation time: 368.359s
// Result: PASS

View File

@@ -0,0 +1,24 @@
async function findShortestPath(graph, start, end) {
const { default: PQ } = await import('https://cdn.skypack.dev/js-priority-queue');
const dist = { [start]: 0 };
const pq = new PQ({ comparator: (a, b) => a.w - b.w });
pq.queue({ v: start, w: 0 });
while (pq.length) {
const { v, w } = pq.dequeue();
if (v === end) return w;
if (w > (dist[v] ?? Infinity)) continue;
for (const n in graph[v]) {
const d = w + graph[v][n];
if (d < (dist[n] ?? Infinity)) {
dist[n] = d;
pq.queue({ v: n, w: d });
}
}
}
return Infinity;
}
export default findShortestPath;
// Generation time: 31.439s
// Result: PASS

View File

@@ -0,0 +1,28 @@
const findConvexHull = async points => {
const { sortBy, uniqWith, isEqual } = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.js');
if (points.length <= 2) return uniqWith(points, isEqual);
const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
const sorted = sortBy(points, ['x', 'y']);
const build = pts => {
const h = [];
for (const p of pts) {
while (h.length > 1 && cross(h.at(-2), h.at(-1), p) <= 0) h.pop();
h.push(p);
}
return h;
};
const lower = build(sorted);
const upper = build(sorted.reverse());
lower.pop();
upper.pop();
return uniqWith([...lower, ...upper], isEqual);
};
export default findConvexHull;
// Generation time: 122.181s
// Result: PASS

View File

@@ -0,0 +1,12 @@
async function findLISLength(nums) {
const { bisectLeft } = await import('https://esm.sh/d3-array@3');
const tails = [];
for (const n of nums) {
const i = bisectLeft(tails, n);
i < tails.length ? tails[i] = n : tails.push(n);
}
return tails.length;
}
export default findLISLength;
// Generation time: 96.878s
// Result: PASS

View File

@@ -0,0 +1,7 @@
const renderTemplate = async (t, d) => {
const { default: H } = await import('https://esm.sh/handlebars');
return H.compile(t)(d);
};
export default renderTemplate;
// Generation time: 42.272s
// Result: PASS

View File

@@ -0,0 +1,5 @@
const parseMarkdown = async md =>
(await import('https://esm.sh/marked')).default(md);
export default parseMarkdown;
// Generation time: 41.263s
// Result: FAIL

View File

@@ -0,0 +1,19 @@
const processCSV = async (csv, { filterColumn: fc, filterValue: fv, groupBy: gb, aggregateColumn: ac, operation: op }) => {
const Papa = (await import('https://cdn.jsdelivr.net/npm/papaparse@5.4.1/papaparse.min.js')).default;
const groups = Papa.parse(csv, { header: true }).data
.filter(r => r[fc] == fv)
.reduce((acc, r) => {
const key = r[gb];
acc[key] = acc[key] || { s: 0, c: 0 };
acc[key].s += Number(r[ac]) || 0;
acc[key].c++;
return acc;
}, {});
return Object.entries(groups).map(([key, { s, c }]) => ({
[gb]: key,
result: op === 'sum' ? s : op === 'avg' ? s / c : c
}));
};
export default processCSV;
// Generation time: 57.701s
// Result: FAIL

View File

@@ -0,0 +1,38 @@
const findAvailableSlots = async (c1, c2, { durationMinutes, searchRange, workHours }) => {
const { parseISO, addMinutes, eachDayOfInterval, min, max } = await import('https://esm.sh/date-fns');
const iso = d => d.toISOString();
const busy = [...c1, ...c2]
.map(b => ({ start: parseISO(b.start), end: parseISO(b.end) }))
.sort((a, b) => a.start - b.start)
.reduce((a, c) => {
if (!a.length || a[a.length - 1].end < c.start) a.push(c);
else a[a.length - 1].end = new Date(Math.max(a[a.length - 1].end, c.end));
return a;
}, []);
const range = { start: parseISO(searchRange.start), end: parseISO(searchRange.end) };
return eachDayOfInterval(range).flatMap(day => {
const [sh, sm] = workHours.start.split(':').map(Number);
const [eh, em] = workHours.end.split(':').map(Number);
let s = new Date(day); s.setUTCHours(sh, sm, 0, 0);
let e = new Date(day); e.setUTCHours(eh, em, 0, 0);
s = max([s, range.start]);
e = min([e, range.end]);
if (s >= e) return [];
const slots = [];
let cur = s;
while (cur < e) {
const nxt = addMinutes(cur, durationMinutes);
const overlap = busy.find(b => cur < b.end && b.start < nxt);
if (overlap) cur = overlap.end;
else if (nxt <= e) slots.push({ start: iso(cur), end: iso(nxt) }), cur = nxt;
else break;
}
return slots;
});
};
export default findAvailableSlots;
// Generation time: 257.354s
// Result: PASS

View File

@@ -0,0 +1,9 @@
const validateJSON = async (data, schema) => {
const { default: Ajv } = await import('https://esm.sh/ajv');
const ajv = new Ajv();
const valid = ajv.validate(schema, data);
return { valid, errors: ajv.errors?.map(e => e.message) || [] };
};
export default validateJSON;
// Generation time: 57.602s
// Result: PASS

View File

@@ -0,0 +1,19 @@
const createStreamVisualizer = async (iterable, { maxPoints, alpha, width, height, yDomain }) => {
const d3 = await import('https://cdn.jsdelivr.net/npm/d3@7/+esm');
const data = [];
let ema;
for await (const { timestamp, value } of iterable) {
ema = ema === undefined ? value : alpha * value + (1 - alpha) * ema;
data.push({ timestamp, value, ema });
if (data.length > maxPoints) data.shift();
}
const x = d3.scaleLinear().domain([data[0].timestamp, data.at(-1).timestamp]).range([0, width]);
const y = d3.scaleLinear().domain(yDomain).range([height, 0]);
return { data, path: d3.line().x(d => x(d.timestamp)).y(d => y(d.ema))(data) };
};
export default createStreamVisualizer;
// Generation time: 86.368s
// Result: PASS