mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-04-06 20:32:14 +00:00
Docs: Update benchmark for minimax/minimax-m2.7
This commit is contained in:
9
tests/10_scrypt_hash/outputs/minimax_minimax-m2.7.js
Normal file
9
tests/10_scrypt_hash/outputs/minimax_minimax-m2.7.js
Normal file
@@ -0,0 +1,9 @@
|
||||
export async function hashPassword(password, salt) {
|
||||
const { scrypt } = await import('https://cdn.jsdelivr.net/npm/scrypt-js/+esm');
|
||||
const { encode } = new TextEncoder();
|
||||
const hash = await scrypt(encode(password), encode(salt), 1024, 8, 1, 32);
|
||||
return [...hash].map(b => b.toString(16).padStart(2, '0')).join('');
|
||||
}
|
||||
export default hashPassword;
|
||||
// Generation time: 47.834s
|
||||
// Result: FAIL
|
||||
14
tests/11_geospatial/outputs/minimax_minimax-m2.7.js
Normal file
14
tests/11_geospatial/outputs/minimax_minimax-m2.7.js
Normal file
@@ -0,0 +1,14 @@
|
||||
async function analyzeGPS(readings, boundary) {
|
||||
const mod = await import('https://cdn.jsdelivr.net/npm/@turf/turf/turf.mjs');
|
||||
const turf = mod.default || mod;
|
||||
const pts = readings.filter(r => {
|
||||
const p = turf.point(r.loc);
|
||||
return turf.booleanPointInPolygon(p, boundary) && !turf.booleanPointOnPolygon(p, boundary);
|
||||
});
|
||||
if (pts.length < 2) return 0;
|
||||
pts.sort((a, b) => a.ts - b.ts);
|
||||
return Math.round(turf.length(turf.lineString(pts.map(p => p.loc)), {units: 'kilometers'}) * 100) / 100;
|
||||
}
|
||||
export default analyzeGPS;
|
||||
// Generation time: 211.389s
|
||||
// Result: FAIL
|
||||
47
tests/12_mst_pipeline/outputs/minimax_minimax-m2.7.js
Normal file
47
tests/12_mst_pipeline/outputs/minimax_minimax-m2.7.js
Normal file
@@ -0,0 +1,47 @@
|
||||
async function computeMST(toml) {
|
||||
const [smol, mne, txt] = 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 { parse } = smol;
|
||||
const { Heap } = mne;
|
||||
const textTable = txt.default || txt;
|
||||
const { edges } = parse(toml);
|
||||
const nodes = [...new Set(edges.flatMap(e => [e.from, e.to]))];
|
||||
const heap = new Heap((a, b) => a.weight - b.weight);
|
||||
edges.forEach(e => heap.push(e));
|
||||
const parent = new Map();
|
||||
const rank = new Map();
|
||||
nodes.forEach(n => { parent.set(n, n); rank.set(n, 0); });
|
||||
const find = x => {
|
||||
while (parent.get(x) !== x) {
|
||||
parent.set(x, parent.get(parent.get(x)));
|
||||
x = parent.get(x);
|
||||
}
|
||||
return x;
|
||||
};
|
||||
const union = (x, y) => {
|
||||
const px = find(x), py = find(y);
|
||||
if (px === py) return false;
|
||||
const rx = rank.get(px), ry = rank.get(py);
|
||||
if (rx < ry) parent.set(px, py);
|
||||
else if (rx > ry) parent.set(py, px);
|
||||
else { parent.set(py, px); rank.set(px, rx + 1); }
|
||||
return true;
|
||||
};
|
||||
const mst = [];
|
||||
let total = 0;
|
||||
while (mst.length < nodes.length - 1 && heap.size) {
|
||||
const e = heap.pop();
|
||||
if (union(e.from, e.to)) {
|
||||
mst.push([e.from, e.to, String(e.weight)]);
|
||||
total += e.weight;
|
||||
}
|
||||
}
|
||||
const table = textTable([['From', 'To', 'Weight'], ...mst]);
|
||||
return { table, totalWeight: total };
|
||||
}
|
||||
export default computeMST;
|
||||
// Generation time: 303.821s
|
||||
// Result: PASS
|
||||
25
tests/1_dijkstra/outputs/minimax_minimax-m2.7.js
Normal file
25
tests/1_dijkstra/outputs/minimax_minimax-m2.7.js
Normal file
@@ -0,0 +1,25 @@
|
||||
const findShortestPath = async (graph, start, end) => {
|
||||
const mod = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/lib/priority-queue.js');
|
||||
const PriorityQueue = mod.default ?? mod.PriorityQueue ?? mod;
|
||||
const dist = {};
|
||||
for (const v of Object.keys(graph)) dist[v] = Infinity;
|
||||
const pq = new PriorityQueue({ comparator: (a, b) => a.dist - b.dist });
|
||||
pq.push({ node: start, dist: 0 });
|
||||
dist[start] = 0;
|
||||
while (pq.length) {
|
||||
const { node, dist: d } = pq.pop();
|
||||
if (node === end) return d;
|
||||
if (d > dist[node]) continue;
|
||||
for (const [n, w] of Object.entries(graph[node] ?? {})) {
|
||||
const nd = d + w;
|
||||
if (nd < (dist[n] ?? Infinity)) {
|
||||
dist[n] = nd;
|
||||
pq.push({ node: n, dist: nd });
|
||||
}
|
||||
}
|
||||
}
|
||||
return Infinity;
|
||||
};
|
||||
export default findShortestPath;
|
||||
// Generation time: 66.576s
|
||||
// Result: FAIL
|
||||
26
tests/2_convex_hull/outputs/minimax_minimax-m2.7.js
Normal file
26
tests/2_convex_hull/outputs/minimax_minimax-m2.7.js
Normal file
@@ -0,0 +1,26 @@
|
||||
async function findConvexHull(points) {
|
||||
const _ = await import('https://esm.sh/lodash@4');
|
||||
const pts = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y']);
|
||||
if (pts.length <= 1) return pts;
|
||||
|
||||
const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
|
||||
|
||||
const lower = [];
|
||||
for (const p of pts) {
|
||||
while (lower.length >= 2 && cross(lower[lower.length - 2], lower[lower.length - 1], p) <= 0) lower.pop();
|
||||
lower.push(p);
|
||||
}
|
||||
|
||||
const upper = [];
|
||||
for (const p of pts.slice().reverse()) {
|
||||
while (upper.length >= 2 && cross(upper[upper.length - 2], upper[upper.length - 1], p) <= 0) upper.pop();
|
||||
upper.push(p);
|
||||
}
|
||||
|
||||
lower.pop();
|
||||
upper.pop();
|
||||
return lower.concat(upper);
|
||||
}
|
||||
export default findConvexHull;
|
||||
// Generation time: 43.347s
|
||||
// Result: PASS
|
||||
51
tests/3_signal_pipeline/outputs/minimax_minimax-m2.7.js
Normal file
51
tests/3_signal_pipeline/outputs/minimax_minimax-m2.7.js
Normal file
@@ -0,0 +1,51 @@
|
||||
async function analyzeSignal(yamlString) {
|
||||
const [{ load }, math, { default: ndarray }, { default: fft }, { default: sanitize }] = await Promise.all([
|
||||
import('https://cdn.jsdelivr.net/npm/js-yaml@4.1.0/+esm'),
|
||||
import('https://cdn.jsdelivr.net/npm/mathjs@11.5.0/+esm'),
|
||||
import('https://esm.sh/ndarray'),
|
||||
import('https://esm.sh/ndarray-fft'),
|
||||
import('https://cdn.jsdelivr.net/npm/dompurify@2.4.0/+esm')
|
||||
]);
|
||||
|
||||
const { sampleRate, duration, components } = load(yamlString);
|
||||
const N = sampleRate * duration;
|
||||
|
||||
const signal = new Float64Array(N);
|
||||
for (let i = 0; i < N; i++) {
|
||||
const t = i / sampleRate;
|
||||
let sum = 0;
|
||||
for (const { frequency, amplitude } of components) {
|
||||
const omega = math.multiply(2 * math.pi, frequency);
|
||||
sum += amplitude * math.sin(math.multiply(omega, t));
|
||||
}
|
||||
signal[i] = sum;
|
||||
}
|
||||
|
||||
const real = ndarray(signal, [N]);
|
||||
const imag = ndarray(new Float64Array(N), [N]);
|
||||
fft(1, real, imag);
|
||||
|
||||
const halfN = N / 2;
|
||||
const peaks = [];
|
||||
for (let k = 0; k <= halfN; k++) {
|
||||
const re = real.get(k);
|
||||
const im = imag.get(k);
|
||||
const magnitude = math.sqrt(re * re + im * im) / halfN;
|
||||
if (magnitude > 0.1) {
|
||||
const frequencyHz = Math.round(k * sampleRate / N);
|
||||
peaks.push({ frequencyHz, magnitude: Math.round(magnitude * 100) / 100 });
|
||||
}
|
||||
}
|
||||
peaks.sort((a, b) => b.magnitude - a.magnitude);
|
||||
|
||||
let html = '<table><tr><th>Frequency (Hz)</th><th>Magnitude</th></tr>';
|
||||
for (const { frequencyHz, magnitude } of peaks) {
|
||||
html += `<tr><td>${frequencyHz}</td><td>${magnitude}</td></tr>`;
|
||||
}
|
||||
html += '</table>';
|
||||
|
||||
return { peaks, html: sanitize(html), signalLength: N };
|
||||
}
|
||||
export default analyzeSignal;
|
||||
// Generation time: 134.381s
|
||||
// Result: FAIL
|
||||
58
tests/4_hexchain_pipeline/outputs/minimax_minimax-m2.7.js
Normal file
58
tests/4_hexchain_pipeline/outputs/minimax_minimax-m2.7.js
Normal file
@@ -0,0 +1,58 @@
|
||||
async function hexchain(s) {
|
||||
const [smol, sr, ss, AjvMod, tbl, dp] = await Promise.all([
|
||||
import('https://cdn.jsdelivr.net/npm/smol-toml@1.1.2/dist/smol-toml.esm.js'),
|
||||
import('https://cdn.jsdelivr.net/npm/seedrandom@3.0.5/seedrandom.min.js'),
|
||||
import('https://cdn.jsdelivr.net/npm/simple-statistics@7.8.3/+esm'),
|
||||
import('https://cdn.jsdelivr.net/npm/ajv@8.11.0/dist/ajv.bundle.min.js'),
|
||||
import('https://cdn.jsdelivr.net/npm/text-table@3.1.0/index.js'),
|
||||
import('https://cdn.jsdelivr.net/npm/dompurify@3.0.6/dist/purify.esm.js')
|
||||
]);
|
||||
|
||||
const parseToml = smol.default || smol;
|
||||
const seedrandom = sr.default || sr;
|
||||
const { mean, standardDeviation, median } = ss;
|
||||
const Ajv = AjvMod.default || AjvMod;
|
||||
const textTable = tbl.default || tbl;
|
||||
const DOMPurify = dp.default || dp;
|
||||
|
||||
const cfg = parseToml.parse(s);
|
||||
const ajv = new Ajv();
|
||||
const schema = {
|
||||
type: 'object',
|
||||
required: ['seed', 'count', 'label'],
|
||||
properties: {
|
||||
seed: { type: 'string' },
|
||||
count: { type: 'integer', minimum: 1, maximum: 10000 },
|
||||
label: { type: 'string', minLength: 1 }
|
||||
}
|
||||
};
|
||||
if (!ajv.validate(schema, cfg)) return { valid: false, errors: ajv.errorsText() };
|
||||
|
||||
const rng = new seedrandom(cfg.seed);
|
||||
const nums = Array.from({ length: cfg.count }, () => rng());
|
||||
|
||||
const r6 = v => Math.round(v * 1e6) / 1e6;
|
||||
const meanVal = r6(mean(nums));
|
||||
const stddevVal = r6(standardDeviation(nums));
|
||||
const medianVal = r6(median(nums));
|
||||
|
||||
const rows = [
|
||||
['Stat', 'Value'],
|
||||
['mean', String(meanVal)],
|
||||
['stddev', String(stddevVal)],
|
||||
['median', String(medianVal)]
|
||||
];
|
||||
const tableStr = textTable(rows);
|
||||
const html = DOMPurify.sanitize(`<pre class="stats">${tableStr}</pre>`);
|
||||
|
||||
return {
|
||||
valid: true,
|
||||
label: cfg.label,
|
||||
stats: { mean: meanVal, stddev: stddevVal, median: medianVal },
|
||||
table: html,
|
||||
count: cfg.count
|
||||
};
|
||||
}
|
||||
export default hexchain;
|
||||
// Generation time: 119.316s
|
||||
// Result: FAIL
|
||||
15
tests/5_markdown_parser/outputs/minimax_minimax-m2.7.js
Normal file
15
tests/5_markdown_parser/outputs/minimax_minimax-m2.7.js
Normal file
@@ -0,0 +1,15 @@
|
||||
export async function parseMarkdown(m) {
|
||||
try {
|
||||
const [{ marked }, { default: DP }] = await Promise.all([
|
||||
import("https://esm.sh/marked"),
|
||||
import("https://esm.sh/dompurify")
|
||||
]);
|
||||
marked.setOptions({ gfm: true });
|
||||
return DP.sanitize(marked.parse(m));
|
||||
} catch (_) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
export default parseMarkdown;
|
||||
// Generation time: 64.285s
|
||||
// Result: PASS
|
||||
43
tests/6_csv_processor/outputs/minimax_minimax-m2.7.js
Normal file
43
tests/6_csv_processor/outputs/minimax_minimax-m2.7.js
Normal file
@@ -0,0 +1,43 @@
|
||||
async function processCSV(csvString, config) {
|
||||
const {
|
||||
filterColumn,
|
||||
filterValue,
|
||||
groupBy,
|
||||
aggregateColumn,
|
||||
operation
|
||||
} = config;
|
||||
|
||||
const { default: Papa } = await import('https://esm.sh/papaparse');
|
||||
const { data: rows, errors } = Papa.parse(csvString, {
|
||||
header: true,
|
||||
skipEmptyLines: true
|
||||
});
|
||||
|
||||
if (errors.length) throw new Error('CSV parsing failed: ' + errors[0].message);
|
||||
|
||||
const filtered = rows.filter(r => r[filterColumn] == filterValue);
|
||||
const groups = new Map();
|
||||
|
||||
for (const row of filtered) {
|
||||
const key = row[groupBy];
|
||||
if (!groups.has(key)) groups.set(key, { sum: 0, count: 0 });
|
||||
const entry = groups.get(key);
|
||||
const num = Number(row[aggregateColumn]);
|
||||
entry.sum += isNaN(num) ? 0 : num;
|
||||
entry.count++;
|
||||
}
|
||||
|
||||
const resultArr = [...groups].map(([key, val]) => {
|
||||
let result;
|
||||
if (operation === 'sum') result = val.sum;
|
||||
else if (operation === 'avg') result = val.count ? val.sum / val.count : 0;
|
||||
else if (operation === 'count') result = val.count;
|
||||
else throw new Error('Unsupported operation: ' + operation);
|
||||
return { [groupBy]: key, result };
|
||||
});
|
||||
|
||||
return resultArr;
|
||||
}
|
||||
export default processCSV;
|
||||
// Generation time: 61.787s
|
||||
// Result: PASS
|
||||
52
tests/7_scheduler/outputs/minimax_minimax-m2.7.js
Normal file
52
tests/7_scheduler/outputs/minimax_minimax-m2.7.js
Normal file
@@ -0,0 +1,52 @@
|
||||
async function findAvailableSlots(calendar1, calendar2, constraints) {
|
||||
const { durationMinutes, searchRange: { start: rangeStart, end: rangeEnd }, workHours: { start: whStart, end: whEnd } } = constraints;
|
||||
const [sh, sm] = whStart.split(':').map(Number);
|
||||
const [eh, em] = whEnd.split(':').map(Number);
|
||||
const workStartMin = sh * 60 + sm;
|
||||
const workEndMin = eh * 60 + em;
|
||||
const { parseISO, addMinutes, startOfDay, eachDayOfInterval, mergeOverlappingIntervals, min, max } = await import('https://cdn.jsdelivr.net/npm/date-fns@2.30.0/esm/index.js');
|
||||
|
||||
const rangeStartDate = parseISO(rangeStart);
|
||||
const rangeEndDate = parseISO(rangeEnd);
|
||||
|
||||
const allBusy = [...calendar1, ...calendar2]
|
||||
.map(({ start, end }) => ({ start: parseISO(start), end: parseISO(end) }))
|
||||
.filter(({ start, end }) => start < end);
|
||||
|
||||
const mergedBusy = mergeOverlappingIntervals(allBusy);
|
||||
|
||||
const busyInRange = mergedBusy
|
||||
.map(b => ({ start: max(b.start, rangeStartDate), end: min(b.end, rangeEndDate) }))
|
||||
.filter(b => b.start < b.end);
|
||||
|
||||
const freeWindows = [];
|
||||
let cur = rangeStartDate;
|
||||
for (const busy of busyInRange) {
|
||||
if (cur < busy.start) freeWindows.push({ start: cur, end: busy.start });
|
||||
cur = max(cur, busy.end);
|
||||
}
|
||||
if (cur < rangeEndDate) freeWindows.push({ start: cur, end: rangeEndDate });
|
||||
|
||||
const slots = [];
|
||||
for (const win of freeWindows) {
|
||||
const days = eachDayOfInterval({ start: win.start, end: win.end });
|
||||
for (const day of days) {
|
||||
const dayStart = startOfDay(day);
|
||||
const dailyStart = addMinutes(dayStart, workStartMin);
|
||||
const dailyEnd = addMinutes(dayStart, workEndMin);
|
||||
const intersectStart = max(win.start, dailyStart);
|
||||
const intersectEnd = min(win.end, dailyEnd);
|
||||
if (intersectStart >= intersectEnd) continue;
|
||||
let slotStart = intersectStart;
|
||||
while (addMinutes(slotStart, durationMinutes) <= intersectEnd) {
|
||||
const slotEnd = addMinutes(slotStart, durationMinutes);
|
||||
slots.push({ start: slotStart.toISOString(), end: slotEnd.toISOString() });
|
||||
slotStart = slotEnd;
|
||||
}
|
||||
}
|
||||
}
|
||||
return slots;
|
||||
}
|
||||
export default findAvailableSlots;
|
||||
// Generation time: 159.679s
|
||||
// Result: FAIL
|
||||
11
tests/8_json_validator/outputs/minimax_minimax-m2.7.js
Normal file
11
tests/8_json_validator/outputs/minimax_minimax-m2.7.js
Normal file
@@ -0,0 +1,11 @@
|
||||
async function validateJSON(data, schema) {
|
||||
const Ajv = (await import('https://cdn.jsdelivr.net/npm/ajv@8/dist/ajv.bundle.min.js')).default;
|
||||
const ajv = new Ajv({ allErrors: true });
|
||||
const validate = ajv.compile(schema);
|
||||
const valid = validate(data);
|
||||
const errors = valid ? [] : validate.errors.map(e => `${e.instancePath || '/'}: ${e.message}`);
|
||||
return { valid, errors };
|
||||
}
|
||||
export default validateJSON;
|
||||
// Generation time: 25.859s
|
||||
// Result: FAIL
|
||||
24
tests/9_stream_visualizer/outputs/minimax_minimax-m2.7.js
Normal file
24
tests/9_stream_visualizer/outputs/minimax_minimax-m2.7.js
Normal file
@@ -0,0 +1,24 @@
|
||||
async function createStreamVisualizer(asyncIterable, { maxPoints, alpha, width, height, yDomain }) {
|
||||
const data = [];
|
||||
let prevEma;
|
||||
let firstTs;
|
||||
let lastTs;
|
||||
for await (const { timestamp, value } of asyncIterable) {
|
||||
prevEma = prevEma === undefined ? value : alpha * value + (1 - alpha) * prevEma;
|
||||
const point = { timestamp, value, ema: prevEma };
|
||||
data.push(point);
|
||||
if (data.length > maxPoints) data.shift();
|
||||
lastTs = timestamp;
|
||||
if (!firstTs) firstTs = timestamp;
|
||||
}
|
||||
if (!data.length) return { data: [], path: '' };
|
||||
const d3 = await import('https://cdn.jsdelivr.net/npm/d3@7/+esm');
|
||||
const xScale = d3.scaleLinear().domain([firstTs, lastTs]).range([0, width]);
|
||||
const yScale = d3.scaleLinear().domain(yDomain).range([height, 0]);
|
||||
const line = d3.line().x(d => xScale(d.timestamp)).y(d => yScale(d.ema)).curve(d3.curveMonotoneX);
|
||||
const path = line(data);
|
||||
return { data, path };
|
||||
}
|
||||
export default createStreamVisualizer;
|
||||
// Generation time: 51.428s
|
||||
// Result: FAIL
|
||||
Reference in New Issue
Block a user