From 401af17eb6bc262556db2e1c8562742702cd4935 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 23 Dec 2025 02:30:02 +0000 Subject: [PATCH] Docs: Update benchmark for z-ai/glm-4.7 --- tests/10_scrypt_hash/outputs/z-ai_glm-4.7.js | 9 +++ tests/11_geospatial/outputs/z-ai_glm-4.7.js | 14 +++++ tests/1_dijkstra/outputs/z-ai_glm-4.7.js | 27 ++++++++ tests/2_convex_hull/outputs/z-ai_glm-4.7.js | 27 ++++++++ tests/3_lis/outputs/z-ai_glm-4.7.js | 12 ++++ tests/4_transpiler/outputs/z-ai_glm-4.7.js | 7 +++ .../5_markdown_parser/outputs/z-ai_glm-4.7.js | 8 +++ tests/6_csv_processor/outputs/z-ai_glm-4.7.js | 24 ++++++++ tests/7_scheduler/outputs/z-ai_glm-4.7.js | 61 +++++++++++++++++++ .../8_json_validator/outputs/z-ai_glm-4.7.js | 9 +++ .../outputs/z-ai_glm-4.7.js | 19 ++++++ 11 files changed, 217 insertions(+) create mode 100644 tests/10_scrypt_hash/outputs/z-ai_glm-4.7.js create mode 100644 tests/11_geospatial/outputs/z-ai_glm-4.7.js create mode 100644 tests/1_dijkstra/outputs/z-ai_glm-4.7.js create mode 100644 tests/2_convex_hull/outputs/z-ai_glm-4.7.js create mode 100644 tests/3_lis/outputs/z-ai_glm-4.7.js create mode 100644 tests/4_transpiler/outputs/z-ai_glm-4.7.js create mode 100644 tests/5_markdown_parser/outputs/z-ai_glm-4.7.js create mode 100644 tests/6_csv_processor/outputs/z-ai_glm-4.7.js create mode 100644 tests/7_scheduler/outputs/z-ai_glm-4.7.js create mode 100644 tests/8_json_validator/outputs/z-ai_glm-4.7.js create mode 100644 tests/9_stream_visualizer/outputs/z-ai_glm-4.7.js diff --git a/tests/10_scrypt_hash/outputs/z-ai_glm-4.7.js b/tests/10_scrypt_hash/outputs/z-ai_glm-4.7.js new file mode 100644 index 0000000..2d624c9 --- /dev/null +++ b/tests/10_scrypt_hash/outputs/z-ai_glm-4.7.js @@ -0,0 +1,9 @@ +async function hashPassword(password, salt) { + const { default: scrypt } = await import('https://cdn.jsdelivr.net/npm/scrypt-js@3.0.1/+esm'); + const enc = new TextEncoder(); + const hash = await scrypt(enc.encode(password), enc.encode(salt), 1024, 8, 1, 32); + return [...hash].map(b => b.toString(16).padStart(2, '0')).join(''); +} +export default hashPassword; +// Generation time: 33.608s +// Result: FAIL \ No newline at end of file diff --git a/tests/11_geospatial/outputs/z-ai_glm-4.7.js b/tests/11_geospatial/outputs/z-ai_glm-4.7.js new file mode 100644 index 0000000..57bdfc6 --- /dev/null +++ b/tests/11_geospatial/outputs/z-ai_glm-4.7.js @@ -0,0 +1,14 @@ +async function analyzeGPS(readings, boundary) { + const t = await import('https://cdn.jsdelivr.net/npm/@turf/turf/+esm'); + + const valid = readings + .filter(r => t.booleanPointInPolygon(t.point(r.loc), boundary)) + .sort((a, b) => a.ts - b.ts); + + if (valid.length < 2) return 0; + + return +(t.length(t.lineString(valid.map(v => v.loc)), { units: 'kilometers' })).toFixed(2); +} +export default analyzeGPS; +// Generation time: 60.849s +// Result: PASS \ No newline at end of file diff --git a/tests/1_dijkstra/outputs/z-ai_glm-4.7.js b/tests/1_dijkstra/outputs/z-ai_glm-4.7.js new file mode 100644 index 0000000..6924e1b --- /dev/null +++ b/tests/1_dijkstra/outputs/z-ai_glm-4.7.js @@ -0,0 +1,27 @@ +async function findShortestPath(graph, start, end) { + const { default: PriorityQueue } = await import('https://esm.sh/js-priority-queue@1.0.0'); + const pq = new PriorityQueue({ comparator: (a, b) => a[1] - b[1] }); + const costs = { [start]: 0 }; + pq.queue([start, 0]); + + while (pq.length) { + const [node, currentCost] = pq.dequeue(); + + if (node === end) return currentCost; + if (currentCost > costs[node]) continue; + + const neighbors = graph[node] || {}; + for (const [neighbor, weight] of Object.entries(neighbors)) { + const newCost = currentCost + weight; + if (newCost < (costs[neighbor] ?? Infinity)) { + costs[neighbor] = newCost; + pq.queue([neighbor, newCost]); + } + } + } + + return Infinity; +} +export default findShortestPath; +// Generation time: 42.134s +// Result: FAIL \ No newline at end of file diff --git a/tests/2_convex_hull/outputs/z-ai_glm-4.7.js b/tests/2_convex_hull/outputs/z-ai_glm-4.7.js new file mode 100644 index 0000000..279a000 --- /dev/null +++ b/tests/2_convex_hull/outputs/z-ai_glm-4.7.js @@ -0,0 +1,27 @@ +const findConvexHull = async (pts) => { + const { sortBy, uniqWith, isEqual } = await import('https://cdn.skypack.dev/lodash'); + const s = sortBy(uniqWith(pts, isEqual), ['x', 'y']); + if (s.length < 2) return s; + + const cp = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x); + const l = []; + const u = []; + + for (const p of s) { + while (l.length >= 2 && cp(l[l.length - 2], l[l.length - 1], p) <= 0) l.pop(); + l.push(p); + } + + for (let i = s.length - 1; i >= 0; i--) { + const p = s[i]; + while (u.length >= 2 && cp(u[u.length - 2], u[u.length - 1], p) <= 0) u.pop(); + u.push(p); + } + + u.pop(); + l.pop(); + return l.concat(u); +}; +export default findConvexHull; +// Generation time: 55.287s +// Result: PASS \ No newline at end of file diff --git a/tests/3_lis/outputs/z-ai_glm-4.7.js b/tests/3_lis/outputs/z-ai_glm-4.7.js new file mode 100644 index 0000000..446673f --- /dev/null +++ b/tests/3_lis/outputs/z-ai_glm-4.7.js @@ -0,0 +1,12 @@ +async function findLISLength(n) { + const { bisectLeft } = await import('https://cdn.skypack.dev/d3-array'); + const t = []; + for (const v of n) { + const i = bisectLeft(t, v); + i === t.length ? t.push(v) : t[i] = v; + } + return t.length; +} +export default findLISLength; +// Generation time: 41.894s +// Result: PASS \ No newline at end of file diff --git a/tests/4_transpiler/outputs/z-ai_glm-4.7.js b/tests/4_transpiler/outputs/z-ai_glm-4.7.js new file mode 100644 index 0000000..3c7afbf --- /dev/null +++ b/tests/4_transpiler/outputs/z-ai_glm-4.7.js @@ -0,0 +1,7 @@ +const renderTemplate = async (template, data) => { + const { default: H } = await import('https://cdn.jsdelivr.net/npm/handlebars@latest/dist/handlebars.module.js'); + return H.compile(template)(data); +}; +export default renderTemplate; +// Generation time: 39.777s +// Result: FAIL \ No newline at end of file diff --git a/tests/5_markdown_parser/outputs/z-ai_glm-4.7.js b/tests/5_markdown_parser/outputs/z-ai_glm-4.7.js new file mode 100644 index 0000000..1e2f11a --- /dev/null +++ b/tests/5_markdown_parser/outputs/z-ai_glm-4.7.js @@ -0,0 +1,8 @@ +let m; +const parseMarkdown = async (s) => { + m ||= (await import('https://esm.sh/marked')).marked; + return m.parse(s); +}; +export default parseMarkdown; +// Generation time: 125.998s +// Result: PASS \ No newline at end of file diff --git a/tests/6_csv_processor/outputs/z-ai_glm-4.7.js b/tests/6_csv_processor/outputs/z-ai_glm-4.7.js new file mode 100644 index 0000000..734a7ba --- /dev/null +++ b/tests/6_csv_processor/outputs/z-ai_glm-4.7.js @@ -0,0 +1,24 @@ +const processCSV = async (csv, c) => { + const { default: { parse } } = await import('https://esm.sh/papaparse'); + const { data } = parse(csv, { header: true }); + + const groups = data.reduce((a, r) => { + if (r[c.filterColumn] == c.filterValue) { + const k = r[c.groupBy]; + const v = Number(r[c.aggregateColumn]) || 0; + if (!a[k]) a[k] = { sum: 0, count: 0 }; + a[k].sum += v; + a[k].count++; + } + return a; + }, {}); + + return Object.entries(groups).map(([k, g]) => ({ + [c.groupBy]: k, + result: c.operation === 'avg' ? g.sum / g.count : + c.operation === 'count' ? g.count : g.sum + })); +}; +export default processCSV; +// Generation time: 169.513s +// Result: PASS \ No newline at end of file diff --git a/tests/7_scheduler/outputs/z-ai_glm-4.7.js b/tests/7_scheduler/outputs/z-ai_glm-4.7.js new file mode 100644 index 0000000..cd3f448 --- /dev/null +++ b/tests/7_scheduler/outputs/z-ai_glm-4.7.js @@ -0,0 +1,61 @@ +async function findAvailableSlots(cal1, cal2, constraints) { + const { DateTime, Duration } = await import('https://cdn.skypack.dev/luxon'); + + const toDT = (s) => DateTime.fromISO(s, { zone: 'utc' }); + const dur = Duration.fromObject({ minutes: constraints.durationMinutes }); + const rS = toDT(constraints.searchRange.start); + const rE = toDT(constraints.searchRange.end); + + const busy = [...cal1, ...cal2] + .map(b => ({ s: toDT(b.start), e: toDT(b.end) })) + .sort((a, b) => a.s - b.s) + .reduce((a, b) => { + const p = a[a.length - 1]; + if (p && b.s <= p.e) { + p.e = b.e > p.e ? b.e : p.e; + } else { + a.push(b); + } + return a; + }, []); + + const slots = []; + let cur = rS.startOf('day'); + + while (cur < rE) { + const iso = cur.toISODate(); + const wS = toDT(`${iso}T${constraints.workHours.start}`); + const wE = toDT(`${iso}T${constraints.workHours.end}`); + + const s = wS < rS ? rS : wS; + const e = wE > rE ? rE : wE; + + if (s < e) { + let t = s; + for (const b of busy) { + if (b.e <= t) continue; + if (b.s >= e) break; + + if (b.s > t) { + while (t.plus(dur) <= b.s) { + slots.push({ start: t.toISO(), end: t.plus(dur).toISO() }); + t = t.plus(dur); + } + } + t = b.e > t ? b.e : t; + if (t >= e) break; + } + + while (t.plus(dur) <= e) { + slots.push({ start: t.toISO(), end: t.plus(dur).toISO() }); + t = t.plus(dur); + } + } + cur = cur.plus({ days: 1 }); + } + + return slots; +} +export default findAvailableSlots; +// Generation time: 208.769s +// Result: PASS \ No newline at end of file diff --git a/tests/8_json_validator/outputs/z-ai_glm-4.7.js b/tests/8_json_validator/outputs/z-ai_glm-4.7.js new file mode 100644 index 0000000..0461bc7 --- /dev/null +++ b/tests/8_json_validator/outputs/z-ai_glm-4.7.js @@ -0,0 +1,9 @@ +async function validateJSON(data, schema) { + const { default: Ajv } = await import('https://esm.sh/ajv@8'); + const v = new Ajv({ allErrors: true }).compile(schema); + const isValid = v(data); + return { valid: isValid, errors: isValid ? [] : v.errors.map(e => e.message) }; +} +export default validateJSON; +// Generation time: 44.300s +// Result: PASS \ No newline at end of file diff --git a/tests/9_stream_visualizer/outputs/z-ai_glm-4.7.js b/tests/9_stream_visualizer/outputs/z-ai_glm-4.7.js new file mode 100644 index 0000000..8602714 --- /dev/null +++ b/tests/9_stream_visualizer/outputs/z-ai_glm-4.7.js @@ -0,0 +1,19 @@ +async function createStreamVisualizer(stream, { maxPoints, alpha, width, height, yDomain }) { + const { scaleLinear, line } = await import('https://esm.sh/d3'); + const data = []; + let ema; + + for await (const { value, timestamp = Date.now() } of stream) { + ema = ema === undefined ? value : alpha * value + (1 - alpha) * ema; + data.push({ timestamp, value, ema }); + if (data.length > maxPoints) data.shift(); + } + + const x = scaleLinear().domain([data[0]?.timestamp, data.at(-1)?.timestamp]).range([0, width]); + const y = scaleLinear().domain(yDomain).range([height, 0]); + + return { data, path: line().x(d => x(d.timestamp)).y(d => y(d.ema))(data) }; +} +export default createStreamVisualizer; +// Generation time: 111.818s +// Result: PASS \ No newline at end of file