mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-13 16:17:54 +00:00
Docs: Update benchmark for z-ai/glm-4.7
This commit is contained in:
9
tests/10_scrypt_hash/outputs/z-ai_glm-4.7.js
Normal file
9
tests/10_scrypt_hash/outputs/z-ai_glm-4.7.js
Normal file
@@ -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
|
||||||
14
tests/11_geospatial/outputs/z-ai_glm-4.7.js
Normal file
14
tests/11_geospatial/outputs/z-ai_glm-4.7.js
Normal file
@@ -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
|
||||||
27
tests/1_dijkstra/outputs/z-ai_glm-4.7.js
Normal file
27
tests/1_dijkstra/outputs/z-ai_glm-4.7.js
Normal file
@@ -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
|
||||||
27
tests/2_convex_hull/outputs/z-ai_glm-4.7.js
Normal file
27
tests/2_convex_hull/outputs/z-ai_glm-4.7.js
Normal file
@@ -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
|
||||||
12
tests/3_lis/outputs/z-ai_glm-4.7.js
Normal file
12
tests/3_lis/outputs/z-ai_glm-4.7.js
Normal file
@@ -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
|
||||||
7
tests/4_transpiler/outputs/z-ai_glm-4.7.js
Normal file
7
tests/4_transpiler/outputs/z-ai_glm-4.7.js
Normal file
@@ -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
|
||||||
8
tests/5_markdown_parser/outputs/z-ai_glm-4.7.js
Normal file
8
tests/5_markdown_parser/outputs/z-ai_glm-4.7.js
Normal file
@@ -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
|
||||||
24
tests/6_csv_processor/outputs/z-ai_glm-4.7.js
Normal file
24
tests/6_csv_processor/outputs/z-ai_glm-4.7.js
Normal file
@@ -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
|
||||||
61
tests/7_scheduler/outputs/z-ai_glm-4.7.js
Normal file
61
tests/7_scheduler/outputs/z-ai_glm-4.7.js
Normal file
@@ -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
|
||||||
9
tests/8_json_validator/outputs/z-ai_glm-4.7.js
Normal file
9
tests/8_json_validator/outputs/z-ai_glm-4.7.js
Normal file
@@ -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
|
||||||
19
tests/9_stream_visualizer/outputs/z-ai_glm-4.7.js
Normal file
19
tests/9_stream_visualizer/outputs/z-ai_glm-4.7.js
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user