mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-07-18 05:45:46 +00:00
Docs: Update benchmark for moonshotai/kimi-k3 EFF:medium
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
const SCRYPT_URL = "https://cdn.jsdelivr.net/npm/scrypt-js@3.0.1/+esm";
|
||||||
|
|
||||||
|
async function hashPassword(password, salt) {
|
||||||
|
const { scrypt } = await import(SCRYPT_URL);
|
||||||
|
const enc = new TextEncoder();
|
||||||
|
const hash = await scrypt(enc.encode(password), enc.encode(salt), 1024, 8, 1, 32);
|
||||||
|
return Array.from(hash, b => b.toString(16).padStart(2, "0")).join("");
|
||||||
|
}
|
||||||
|
export default hashPassword;
|
||||||
|
// Generation time: 36.726s
|
||||||
|
// Result: PASS
|
||||||
13
tests/11_geospatial/outputs/moonshotai_kimi-k3 EFF_medium.js
Normal file
13
tests/11_geospatial/outputs/moonshotai_kimi-k3 EFF_medium.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
async function analyzeGPS(readings, boundary) {
|
||||||
|
if (!Array.isArray(readings) || readings.length < 2) return 0;
|
||||||
|
const m = await import('https://cdn.jsdelivr.net/npm/@turf/turf@7/+esm');
|
||||||
|
const { booleanPointInPolygon: inside, lineString, length } = m.default ?? m;
|
||||||
|
const coords = readings
|
||||||
|
.filter(({ loc }) => loc && inside(loc, boundary, { ignoreBoundary: true }))
|
||||||
|
.sort((a, b) => a.ts - b.ts)
|
||||||
|
.map(({ loc }) => loc);
|
||||||
|
return coords.length < 2 ? 0 : +length(lineString(coords), { units: 'kilometers' }).toFixed(2);
|
||||||
|
}
|
||||||
|
export default analyzeGPS;
|
||||||
|
// Generation time: 75.533s
|
||||||
|
// Result: PASS
|
||||||
31
tests/2_convex_hull/outputs/moonshotai_kimi-k3 EFF_medium.js
Normal file
31
tests/2_convex_hull/outputs/moonshotai_kimi-k3 EFF_medium.js
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
async function findConvexHull(points) {
|
||||||
|
if (!Array.isArray(points) || points.some(p => !p || !Number.isFinite(p.x) || !Number.isFinite(p.y))) {
|
||||||
|
throw new TypeError('findConvexHull expects an array of finite {x, y} points');
|
||||||
|
}
|
||||||
|
|
||||||
|
const { sortBy, uniqWith } = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/+esm');
|
||||||
|
const ps = uniqWith(
|
||||||
|
sortBy(points.map(({ x, y }) => ({ x, y })), ['x', 'y']),
|
||||||
|
(a, b) => a.x === b.x && a.y === b.y
|
||||||
|
);
|
||||||
|
|
||||||
|
if (ps.length < 3) return ps;
|
||||||
|
|
||||||
|
const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
|
||||||
|
const half = q => {
|
||||||
|
const h = [];
|
||||||
|
for (const p of q) {
|
||||||
|
while (h.length > 1 && cross(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop();
|
||||||
|
h.push(p);
|
||||||
|
}
|
||||||
|
return h;
|
||||||
|
};
|
||||||
|
|
||||||
|
const lo = half(ps);
|
||||||
|
const hi = half([...ps].reverse());
|
||||||
|
|
||||||
|
return [...lo.slice(0, -1), ...hi.slice(0, -1)];
|
||||||
|
}
|
||||||
|
export default findConvexHull;
|
||||||
|
// Generation time: 96.201s
|
||||||
|
// Result: PASS
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
const CDN = [
|
||||||
|
'https://cdn.jsdelivr.net/npm/js-yaml@4.1.0/+esm',
|
||||||
|
'https://cdn.jsdelivr.net/npm/mathjs@13/+esm',
|
||||||
|
'https://cdn.jsdelivr.net/npm/ndarray@1.0.19/+esm',
|
||||||
|
'https://cdn.jsdelivr.net/npm/ndarray-fft@1.0.3/+esm',
|
||||||
|
'https://cdn.jsdelivr.net/npm/dompurify@3.1.6/+esm'
|
||||||
|
];
|
||||||
|
|
||||||
|
let libs;
|
||||||
|
const loadLibs = () => (libs ??= Promise.all(CDN.map((u) => import(u))));
|
||||||
|
const pick = (m, k) => (m?.[k] !== undefined ? m : m?.default ?? m);
|
||||||
|
|
||||||
|
async function analyzeSignal(yamlString) {
|
||||||
|
if (typeof yamlString !== 'string') throw new TypeError('analyzeSignal expects a YAML string');
|
||||||
|
|
||||||
|
const [yamlM, mathM, ndM, fftM, dpM] = await loadLibs();
|
||||||
|
const { load } = pick(yamlM, 'load');
|
||||||
|
const math = pick(mathM, 'sin');
|
||||||
|
const ndarray = ndM?.default ?? ndM;
|
||||||
|
const fft = fftM?.default ?? fftM;
|
||||||
|
const DOMPurify = dpM?.default ?? dpM;
|
||||||
|
|
||||||
|
const { sampleRate, duration, components = [] } = load(yamlString);
|
||||||
|
const N = sampleRate * duration;
|
||||||
|
if (!Number.isInteger(N) || N < 2 || (N & (N - 1))) {
|
||||||
|
throw new RangeError(`sampleRate * duration must be a power of two >= 2 (got ${N})`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = new Float64Array(N);
|
||||||
|
for (let i = 0; i < N; i++) {
|
||||||
|
const t = i / sampleRate;
|
||||||
|
data[i] = components.reduce((s, { frequency: f, amplitude: a }) => s + a * math.sin(2 * math.pi * f * t), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const real = ndarray(data, [N]);
|
||||||
|
const imag = ndarray(new Float64Array(N), [N]);
|
||||||
|
fft(1, real, imag);
|
||||||
|
|
||||||
|
const half = N >> 1;
|
||||||
|
const peaks = Array.from({ length: half + 1 }, (_, k) => ({
|
||||||
|
k,
|
||||||
|
m: math.sqrt(real.get(k) ** 2 + imag.get(k) ** 2) / half
|
||||||
|
}))
|
||||||
|
.filter(({ m }) => m > 0.1)
|
||||||
|
.sort((a, b) => b.m - a.m)
|
||||||
|
.map(({ k, m }) => ({ frequencyHz: Math.round(k * sampleRate / N), magnitude: +m.toFixed(2) }));
|
||||||
|
|
||||||
|
const rows = peaks.map(({ frequencyHz, magnitude }) => `<tr><td>${frequencyHz}</td><td>${magnitude}</td></tr>`).join('');
|
||||||
|
const html = DOMPurify.sanitize(`<table><tr><th>Frequency (Hz)</th><th>Magnitude</th></tr>${rows}</table>`);
|
||||||
|
|
||||||
|
return { peaks, html, signalLength: N };
|
||||||
|
}
|
||||||
|
|
||||||
|
globalThis.analyzeSignal = analyzeSignal;
|
||||||
|
export default analyzeSignal;
|
||||||
|
// Generation time: 203.454s
|
||||||
|
// Result: PASS
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
const CDN = 'https://esm.sh/';
|
||||||
|
|
||||||
|
async function hexchain(toml) {
|
||||||
|
const [tomlM, seedM, ssM, ajvM, ttM, dpM] = await Promise.all(
|
||||||
|
['smol-toml@1', 'seedrandom@3', 'simple-statistics@7', 'ajv@8', 'text-table@0.2', 'dompurify@3']
|
||||||
|
.map(p => import(CDN + p))
|
||||||
|
);
|
||||||
|
|
||||||
|
const config = tomlM.parse(toml);
|
||||||
|
const ajv = new ajvM.default();
|
||||||
|
const valid = ajv.validate({
|
||||||
|
type: 'object',
|
||||||
|
required: ['seed', 'count', 'label'],
|
||||||
|
properties: {
|
||||||
|
seed: { type: 'string' },
|
||||||
|
count: { type: 'integer', minimum: 1, maximum: 10000 },
|
||||||
|
label: { type: 'string', minLength: 1 }
|
||||||
|
}
|
||||||
|
}, config);
|
||||||
|
if (!valid) return { valid: false, errors: ajv.errorsText() };
|
||||||
|
|
||||||
|
const rng = new seedM.default(config.seed);
|
||||||
|
const nums = Array.from({ length: config.count }, () => rng());
|
||||||
|
const r6 = x => Math.round(x * 1e6) / 1e6;
|
||||||
|
const mean = r6(ssM.mean(nums));
|
||||||
|
const stddev = r6(ssM.standardDeviation(nums));
|
||||||
|
const median = r6(ssM.median(nums));
|
||||||
|
|
||||||
|
const table = ttM.default([
|
||||||
|
['Stat', 'Value'],
|
||||||
|
['mean', String(mean)],
|
||||||
|
['stddev', String(stddev)],
|
||||||
|
['median', String(median)]
|
||||||
|
]);
|
||||||
|
|
||||||
|
const dp = dpM.default ?? dpM;
|
||||||
|
const purify = dp.sanitize ? dp : dp(window);
|
||||||
|
|
||||||
|
return {
|
||||||
|
valid: true,
|
||||||
|
label: config.label,
|
||||||
|
stats: { mean, stddev, median },
|
||||||
|
table: purify.sanitize('<pre class="stats">' + table + '</pre>'),
|
||||||
|
count: config.count
|
||||||
|
};
|
||||||
|
}
|
||||||
|
export default hexchain;
|
||||||
|
// Generation time: 84.644s
|
||||||
|
// Result: PASS
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
let libs;
|
||||||
|
|
||||||
|
const load = () => libs ??= Promise.all([
|
||||||
|
import('https://cdn.jsdelivr.net/npm/marked@12.0.2/+esm'),
|
||||||
|
import('https://cdn.jsdelivr.net/npm/dompurify@3.1.5/+esm'),
|
||||||
|
]).then(([{ marked }, { default: purify }]) => ({ marked, purify }));
|
||||||
|
|
||||||
|
async function parseMarkdown(md) {
|
||||||
|
const { marked, purify } = await load();
|
||||||
|
const html = marked.parse(String(md ?? ''), { gfm: true });
|
||||||
|
return purify.sanitize(html, { USE_PROFILES: { html: true } });
|
||||||
|
}
|
||||||
|
export default parseMarkdown;
|
||||||
|
// Generation time: 40.071s
|
||||||
|
// Result: PASS
|
||||||
64
tests/7_scheduler/outputs/moonshotai_kimi-k3 EFF_medium.js
Normal file
64
tests/7_scheduler/outputs/moonshotai_kimi-k3 EFF_medium.js
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
export async function findAvailableSlots(calendar1, calendar2, constraints) {
|
||||||
|
const { DateTime } = await import('https://cdn.jsdelivr.net/npm/luxon@3/+esm');
|
||||||
|
const utc = (s) => DateTime.fromISO(s, { zone: 'utc' });
|
||||||
|
const { durationMinutes, searchRange, workHours } = constraints;
|
||||||
|
const rs = utc(searchRange.start);
|
||||||
|
const re = utc(searchRange.end);
|
||||||
|
|
||||||
|
const busy = [...calendar1, ...calendar2]
|
||||||
|
.map(({ start, end }) => [utc(start), utc(end)])
|
||||||
|
.filter(([s, e]) => e > s)
|
||||||
|
.sort((a, b) => a[0] - b[0]);
|
||||||
|
|
||||||
|
const merged = [];
|
||||||
|
for (const [s, e] of busy) {
|
||||||
|
const last = merged.at(-1);
|
||||||
|
if (last && s <= last[1]) last[1] = e > last[1] ? e : last[1];
|
||||||
|
else merged.push([s, e]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const free = [];
|
||||||
|
let cur = rs;
|
||||||
|
for (const [s, e] of merged) {
|
||||||
|
const bs = s < rs ? rs : s;
|
||||||
|
const be = e > re ? re : e;
|
||||||
|
if (be <= rs || bs >= re) continue;
|
||||||
|
if (bs > cur) free.push([cur, bs]);
|
||||||
|
if (be > cur) cur = be;
|
||||||
|
}
|
||||||
|
if (cur < re) free.push([cur, re]);
|
||||||
|
|
||||||
|
const [sh, sm] = workHours.start.split(':').map(Number);
|
||||||
|
const [eh, em] = workHours.end.split(':').map(Number);
|
||||||
|
const windows = [];
|
||||||
|
for (let d = rs.startOf('day'); d < re; d = d.plus({ days: 1 })) {
|
||||||
|
const ws = d.plus({ hours: sh, minutes: sm });
|
||||||
|
let we = d.plus({ hours: eh, minutes: em });
|
||||||
|
if (we <= ws) we = we.plus({ days: 1 });
|
||||||
|
const s = ws > rs ? ws : rs;
|
||||||
|
const e = we < re ? we : re;
|
||||||
|
if (s < e) windows.push([s, e]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const dur = { minutes: durationMinutes };
|
||||||
|
const iso = (d) => d.toISO({ suppressMilliseconds: true });
|
||||||
|
const slots = [];
|
||||||
|
for (const [fs, fe] of free) {
|
||||||
|
for (const [ws, we] of windows) {
|
||||||
|
if (we <= fs) continue;
|
||||||
|
if (ws >= fe) break;
|
||||||
|
let t = fs > ws ? fs : ws;
|
||||||
|
const end = fe < we ? fe : we;
|
||||||
|
while (true) {
|
||||||
|
const n = t.plus(dur);
|
||||||
|
if (n > end) break;
|
||||||
|
slots.push({ start: iso(t), end: iso(n) });
|
||||||
|
t = n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return slots;
|
||||||
|
}
|
||||||
|
export default findAvailableSlots;
|
||||||
|
// Generation time: 113.083s
|
||||||
|
// Result: PASS
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
async function createStreamVisualizer(asyncIterable, { maxPoints, alpha, width, height, yDomain }) {
|
||||||
|
const { scaleLinear, line } = await import("https://cdn.jsdelivr.net/npm/d3@7/+esm");
|
||||||
|
const data = [];
|
||||||
|
let ema;
|
||||||
|
|
||||||
|
for await (const { timestamp, value } of asyncIterable) {
|
||||||
|
ema = data.length ? alpha * value + (1 - alpha) * ema : value;
|
||||||
|
data.push({ timestamp, value, ema });
|
||||||
|
if (data.length > maxPoints) data.shift();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!data.length) return { data, path: "" };
|
||||||
|
|
||||||
|
const x = scaleLinear()
|
||||||
|
.domain([data[0].timestamp, data.at(-1).timestamp])
|
||||||
|
.range([0, width]);
|
||||||
|
const y = scaleLinear().domain(yDomain).range([height, 0]);
|
||||||
|
|
||||||
|
const path = line()
|
||||||
|
.x(d => x(d.timestamp))
|
||||||
|
.y(d => y(d.ema))(data);
|
||||||
|
|
||||||
|
return { data, path };
|
||||||
|
}
|
||||||
|
export default createStreamVisualizer;
|
||||||
|
// Generation time: 48.702s
|
||||||
|
// Result: PASS
|
||||||
Reference in New Issue
Block a user