From 8ab1e91949db3cac71580715bfef4ee69256d099 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 2 Dec 2025 15:05:25 +0000 Subject: [PATCH] Docs: Update benchmark for minimax/minimax-m2 --- .../outputs/minimax_minimax-m2.js | 18 +++ .../outputs/minimax_minimax-m2.js | 11 ++ .../1_dijkstra/outputs/minimax_minimax-m2.js | 37 +++++ .../outputs/minimax_minimax-m2.js | 25 +++ tests/3_lis/outputs/minimax_minimax-m2.js | 4 + .../outputs/minimax_minimax-m2.js | 20 +++ .../outputs/minimax_minimax-m2.js | 4 + .../outputs/minimax_minimax-m2.js | 27 ++++ .../7_scheduler/outputs/minimax_minimax-m2.js | 142 ++++++++++++++++++ .../outputs/minimax_minimax-m2.js | 44 ++++++ .../outputs/minimax_minimax-m2.js | 55 +++++++ 11 files changed, 387 insertions(+) create mode 100644 tests/10_scrypt_hash/outputs/minimax_minimax-m2.js create mode 100644 tests/11_geospatial/outputs/minimax_minimax-m2.js create mode 100644 tests/1_dijkstra/outputs/minimax_minimax-m2.js create mode 100644 tests/2_convex_hull/outputs/minimax_minimax-m2.js create mode 100644 tests/3_lis/outputs/minimax_minimax-m2.js create mode 100644 tests/4_transpiler/outputs/minimax_minimax-m2.js create mode 100644 tests/5_markdown_parser/outputs/minimax_minimax-m2.js create mode 100644 tests/6_csv_processor/outputs/minimax_minimax-m2.js create mode 100644 tests/7_scheduler/outputs/minimax_minimax-m2.js create mode 100644 tests/8_json_validator/outputs/minimax_minimax-m2.js create mode 100644 tests/9_stream_visualizer/outputs/minimax_minimax-m2.js diff --git a/tests/10_scrypt_hash/outputs/minimax_minimax-m2.js b/tests/10_scrypt_hash/outputs/minimax_minimax-m2.js new file mode 100644 index 0000000..7f8714b --- /dev/null +++ b/tests/10_scrypt_hash/outputs/minimax_minimax-m2.js @@ -0,0 +1,18 @@ +let _scrypt; + +export async function hashPassword(password, salt) { + if (!_scrypt) { + const mod = await import('https://cdn.skypack.dev/scrypt-js'); + _scrypt = mod.default || mod.scrypt; + } + const hash = await _scrypt(new TextEncoder().encode(password), new TextEncoder().encode(salt), { + N: 1024, + r: 8, + p: 1, + dkLen: 32 + }); + return [...hash].map(b => b.toString(16).padStart(2, '0')).join(''); +} +export default hashPassword; +// Generation time: 17.866s +// Result: FAIL \ No newline at end of file diff --git a/tests/11_geospatial/outputs/minimax_minimax-m2.js b/tests/11_geospatial/outputs/minimax_minimax-m2.js new file mode 100644 index 0000000..875f504 --- /dev/null +++ b/tests/11_geospatial/outputs/minimax_minimax-m2.js @@ -0,0 +1,11 @@ +export async function analyzeGPS(readings, boundary) { + const t = await import('https://cdn.skypack.dev/@turf/turf') + const v = readings.filter(r => t.booleanPointInPolygon(r.loc, boundary)).sort((a,b) => a.ts-b.ts) + if(v.length < 2) return 0 + const coords = v.map(r => r.loc) + const line = t.lineString(coords) + return Math.round(t.length(line, {units:'kilometers'})*100)/100 +} +export default analyzeGPS; +// Generation time: 11.219s +// Result: PASS \ No newline at end of file diff --git a/tests/1_dijkstra/outputs/minimax_minimax-m2.js b/tests/1_dijkstra/outputs/minimax_minimax-m2.js new file mode 100644 index 0000000..0ddc05c --- /dev/null +++ b/tests/1_dijkstra/outputs/minimax_minimax-m2.js @@ -0,0 +1,37 @@ +export async function findShortestPath(graph, start, end) { + if (start === end) return 0; + if (!graph || !graph[start] || !graph[end]) return Infinity; + + const { default: PQ } = await import('https://cdn.skypack.dev/js-priority-queue@0.2.0?min') || + (await import('https://unpkg.com/js-priority-queue@0.2.0/dist/js-priority-queue.min.js')) || + { default: self.PriorityQueue }; + const pq = new PQ({ comparator: (a, b) => a.d - b.d }); + + const dist = Object.create(null); + const q = new Set(Object.keys(graph)); + + for (const k of q) dist[k] = Infinity; + dist[start] = 0; + pq.enqueue({ n: start, d: 0 }); + + while (pq.length) { + const { n: u, d: du } = pq.dequeue(); + if (du !== dist[u]) continue; + if (u === end) return du; + const nb = graph[u] || {}; + for (const v in nb) { + if (!q.has(v)) continue; + const w = +nb[v]; + if (!isFinite(w)) continue; + const nd = du + w; + if (nd < dist[v]) { + dist[v] = nd; + pq.enqueue({ n: v, d: nd }); + } + } + } + return Infinity; +} +export default findShortestPath; +// Generation time: 18.720s +// Result: FAIL \ No newline at end of file diff --git a/tests/2_convex_hull/outputs/minimax_minimax-m2.js b/tests/2_convex_hull/outputs/minimax_minimax-m2.js new file mode 100644 index 0000000..c0bfd2d --- /dev/null +++ b/tests/2_convex_hull/outputs/minimax_minimax-m2.js @@ -0,0 +1,25 @@ +export async function findConvexHull(points) { + const _ = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/+esm'); + if (!Array.isArray(points)) points = []; + const uniq = _.uniqWith(points, (a, b) => a.x === b.x && a.y === b.y); + const pts = _.sortBy(uniq, p => [p.x, p.y]); + if (pts.length <= 1) return pts.slice(); + 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 > 1 && cross(lower[lower.length - 2], lower[lower.length - 1], p) <= 0) lower.pop(); + lower.push(p); + } + const upper = []; + for (let i = pts.length - 1; i >= 0; i--) { + const p = pts[i]; + while (upper.length > 1 && cross(upper[upper.length - 2], upper[upper.length - 1], p) <= 0) upper.pop(); + upper.push(p); + } + upper.pop(); + lower.pop(); + return lower.concat(upper); +} +export default findConvexHull; +// Generation time: 14.502s +// Result: PASS \ No newline at end of file diff --git a/tests/3_lis/outputs/minimax_minimax-m2.js b/tests/3_lis/outputs/minimax_minimax-m2.js new file mode 100644 index 0000000..d6ddbce --- /dev/null +++ b/tests/3_lis/outputs/minimax_minimax-m2.js @@ -0,0 +1,4 @@ + +export default findLISLength; +// Generation time: 10.991s +// Result: FAIL \ No newline at end of file diff --git a/tests/4_transpiler/outputs/minimax_minimax-m2.js b/tests/4_transpiler/outputs/minimax_minimax-m2.js new file mode 100644 index 0000000..2c75adb --- /dev/null +++ b/tests/4_transpiler/outputs/minimax_minimax-m2.js @@ -0,0 +1,20 @@ +export async function renderTemplate(template, data) { + const load = async () => { + try { + const src = 'https://cdn.jsdelivr.net/npm/handlebars@4.7.7/dist/handlebars.min.js' + const mod = await import(src) + return mod.default || mod.Handlebars || mod + } catch (e) { + const alt = 'https://unpkg.com/handlebars@4.7.7/dist/handlebars.min.js' + const mod2 = await import(alt) + return mod2.default || mod2.Handlebars || mod2 + } + } + const hbs = await load() + const s = String(template) + const f = hbs.compile(s, { noEscape: false }) + return f(data) +} +export default renderTemplate; +// Generation time: 13.350s +// Result: FAIL \ No newline at end of file diff --git a/tests/5_markdown_parser/outputs/minimax_minimax-m2.js b/tests/5_markdown_parser/outputs/minimax_minimax-m2.js new file mode 100644 index 0000000..8955eb4 --- /dev/null +++ b/tests/5_markdown_parser/outputs/minimax_minimax-m2.js @@ -0,0 +1,4 @@ +const parseMarkdown=async e=>(await import("https://cdn.jsdelivr.net/npm/markdown-it@13.0.2/dist/markdown-it.min.js")).default().render(e) +export default parseMarkdown; +// Generation time: 9.601s +// Result: FAIL \ No newline at end of file diff --git a/tests/6_csv_processor/outputs/minimax_minimax-m2.js b/tests/6_csv_processor/outputs/minimax_minimax-m2.js new file mode 100644 index 0000000..cafc1b0 --- /dev/null +++ b/tests/6_csv_processor/outputs/minimax_minimax-m2.js @@ -0,0 +1,27 @@ +async function processCSV(csvString, config) { + const [{ default: Papa }, { groupBy, sumBy, meanBy }] = await Promise.all([ + import('https://cdn.jsdelivr.net/npm/papaparse@5.4.1/+esm'), + import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/+esm') + ]); + + const data = Papa.parse(csvString, { header: true }).data.filter(row => + row[config.filterColumn] == config.filterValue + ); + + const grouped = groupBy(data, config.groupBy); + + return Object.entries(grouped).map(([key, rows]) => { + let result; + const numRows = rows.map(r => parseFloat(r[config.aggregateColumn]) || 0); + + switch(config.operation) { + case 'sum': result = numRows.reduce((a, b) => a + b, 0); break; + case 'avg': result = numRows.reduce((a, b) => a + b, 0) / numRows.length; break; + case 'count': result = numRows.length; break; + } + return { [config.groupBy]: key, result }; + }); +} +export default processCSV; +// Generation time: 5.258s +// Result: PASS \ No newline at end of file diff --git a/tests/7_scheduler/outputs/minimax_minimax-m2.js b/tests/7_scheduler/outputs/minimax_minimax-m2.js new file mode 100644 index 0000000..36a72c1 --- /dev/null +++ b/tests/7_scheduler/outputs/minimax_minimax-m2.js @@ -0,0 +1,142 @@ +'use strict'; + +export async function findAvailableSlots(busyA, busyB, constraints) { + const { + addMinutes, + compareAsc, + eachMinuteOfInterval, + isBefore, + isEqual, + isValid, + parseISO, + startOfDay, + } = await import('https://cdn.skypack.dev/date-fns@2.30.0'); + + const c = constraints || {}; + const durationMinutes = (c && c.durationMinutes) || 30; + if (!Number.isInteger(durationMinutes) || durationMinutes <= 0) throw new Error('durationMinutes must be a positive integer'); + const range = c && c.searchRange || {}; + const rangeStart = parseISO(range.start); + const rangeEnd = parseISO(range.end); + if (!isValid(rangeStart) || !isValid(rangeEnd) || !isBefore(rangeStart, rangeEnd)) throw new Error('Invalid searchRange'); + const wh = c && c.workHours || {}; + const [whStartH, whStartM] = String(wh.start || '09:00').split(':').map(n => parseInt(n, 10)); + const [whEndH, whEndM] = String(wh.end || '17:00').split(':').split(':').map(n => parseInt(n, 10)); + const WH_ST = whStartH * 60 + (isNaN(whStartM) ? 0 : whStartM); + const WH_ET = whEndH * 60 + (isNaN(whEndM) ? 0 : whEndM); + if (!(0 <= WH_ST && WH_ST < WH_ET && WH_ET <= 1440)) throw new Error('Invalid workHours'); + + const toEpoch = d => d.getTime(); + const fmtTime = d => { + const t = d.getUTCHours().toString().padStart(2, '0') + ':' + d.getUTCMinutes().toString().padStart(2, '0'); + return t; + }; + + const parseBusy = slot => { + const s = parseISO(slot.start); + const e = parseISO(slot.end); + if (!isValid(s) || !isValid(e) || !isBefore(s, e) && !isEqual(s, e)) throw new Error('Invalid busy slot'); + return { s, e }; + }; + + const busy = [...busyA, ...busyB].map(parseBusy) + .filter(({ s, e }) => isBefore(rangeStart, e) && !isBefore(s, rangeEnd)) + .map(({ s, e }) => ({ s: isBefore(s, rangeStart) ? rangeStart : s, e: isBefore(rangeEnd, e) ? rangeEnd : e })) + .sort((a, b) => compareAsc(a.s, b.s)); + + const merged = []; + for (const cur of busy) { + if (merged.length === 0) { + merged.push({ ...cur }); + continue; + } + const last = merged[merged.length - 1]; + if (isBefore(last.e, cur.s) || isEqual(last.e, cur.s)) { + merged.push({ ...cur }); + } else { + if (isBefore(cur.e, last.e)) continue; + last.e = cur.e; + } + } + + const findNext = (t, arr, lo, hi) => { + while (lo <= hi) { + const mid = (lo + hi) >> 1; + if (isBefore(arr[mid].e, t) || isEqual(arr[mid].e, t)) lo = mid + 1; + else hi = mid - 1; + } + return lo < arr.length ? lo : -1; + }; + + const available = []; + let cursor = rangeStart; + let idx = 0; + while (idx < merged.length && !isBefore(rangeEnd, merged[idx].s)) { + const blockStart = merged[idx].s; + const blockEnd = merged[idx].e; + if (isBefore(cursor, blockStart)) { + available.push({ start: cursor, end: blockStart }); + } + if (isBefore(blockEnd, cursor)) { + idx = findNext(cursor, merged, idx + 1, merged.length - 1); + if (idx === -1) break; + continue; + } + cursor = blockEnd; + idx = idx + 1; + } + if (isBefore(cursor, rangeEnd)) available.push({ start: cursor, end: rangeEnd }); + + const isSameUTCDay = (a, b) => + a.getUTCFullYear() === b.getUTCFullYear() && + a.getUTCMonth() === b.getUTCMonth() && + a.getUTCDate() === b.getUTCDate(); + + const startOfNextDayUTC = d => addMinutes(startOfDay(d), 24 * 60); + + const clipSegmentToWorkHours = (segStart, segEnd) => { + const out = []; + let day = startOfDay(segStart); + while (isBefore(day, segEnd)) { + const dayStart = isBefore(day, segStart) ? segStart : day; + const dayNext = startOfNextDayUTC(day); + const dayEnd = isBefore(segEnd, dayNext) ? segEnd : dayNext; + const segST = (dayStart.getUTCHours() * 60 + dayStart.getUTCMinutes()) | 0; + const segET = (dayEnd.getUTCHours() * 60 + dayEnd.getUTCMinutes()) | 0; + const st = Math.max(segST, WH_ST); + const et = Math.min(segET, WH_ET); + if (st < et) { + const clipStart = addMinutes(day, st); + const clipEnd = addMinutes(day, et); + out.push({ start: clipStart, end: clipEnd }); + } + day = dayNext; + } + return out; + }; + + const slots = []; + for (const seg of available) { + const clips = clipSegmentToWorkHours(seg.start, seg.end); + for (const clip of clips) { + const clipLen = Math.floor((toEpoch(clip.end) - toEpoch(clip.start)) / 60000); + const count = Math.floor(clipLen / durationMinutes); + if (count <= 0) continue; + let cur = clip.start; + for (let i = 0; i < count; i++) { + const s = cur; + const e = addMinutes(s, durationMinutes); + if (isBefore(e, clip.end) || isEqual(e, clip.end)) { + if (isBefore(rangeStart, s) && !isBefore(rangeEnd, e)) { + slots.push({ start: s.toISOString(), end: e.toISOString() }); + } + } + cur = e; + } + } + } + return slots; +} +export default findAvailableSlots; +// Generation time: 36.069s +// Result: FAIL \ No newline at end of file diff --git a/tests/8_json_validator/outputs/minimax_minimax-m2.js b/tests/8_json_validator/outputs/minimax_minimax-m2.js new file mode 100644 index 0000000..aa24d9b --- /dev/null +++ b/tests/8_json_validator/outputs/minimax_minimax-m2.js @@ -0,0 +1,44 @@ +export async function validateJSON(data, schema) { + try { + const AjvMod = await import('https://esm.sh/ajv@8.17.1'); + const FormatsMod = await import('https://esm.sh/ajv-formats@3.0.1?deps=ajv@8.17.1'); + const Ajv = AjvMod.default; + const addFormats = FormatsMod.default; + + const ajv = new Ajv({ allErrors: true, strict: false, allowUnionTypes: true }); + addFormats(ajv); + + if (schema && typeof schema === 'object' && schema.$schema && typeof schema.$schema === 'string') { + try { ajv.addMetaSchema(JSON.parse(schema.$schema)); } catch {} + } + + const validate = ajv.compile(schema); + const valid = validate(data); + + if (valid) return { valid: true, errors: [] }; + + const errors = validate.errors.map(err => { + const path = err.instancePath || ''; + const loc = path.replace(/\//g, '.').replace(/^\./, '') || 'root'; + let msg = `${loc} ${err.message}`; + if (err.params) { + const params = Object.assign({}, err.params); + if (params.limit !== undefined) msg += ` (limit=${params.limit})`; + if (params.type) msg += ` (type=${params.type})`; + if (params.format) msg += ` (format=${params.format})`; + if (params.pattern) msg += ` (pattern=${params.pattern})`; + if (params.missingProperty) msg += ` (missingProperty=${params.missingProperty})`; + if (params.additionalProperty) msg += ` (additionalProperty=${params.additionalProperty})`; + if (params.existingCount !== undefined && params.allowedLength !== undefined) msg += ` (count=${params.existingCount}/${params.allowedLength})`; + } + return msg; + }); + + return { valid: false, errors }; + } catch (e) { + return { valid: false, errors: [String(e && e.message || e)] }; + } +} +export default validateJSON; +// Generation time: 22.759s +// Result: PASS \ No newline at end of file diff --git a/tests/9_stream_visualizer/outputs/minimax_minimax-m2.js b/tests/9_stream_visualizer/outputs/minimax_minimax-m2.js new file mode 100644 index 0000000..02a9786 --- /dev/null +++ b/tests/9_stream_visualizer/outputs/minimax_minimax-m2.js @@ -0,0 +1,55 @@ +export async function createStreamVisualizer(stream, opts = {}) { + const { + maxPoints = 1000, + alpha = 0.2, + width = 800, + height = 300, + yDomain = [-1, 1] + } = opts; + + if (alpha <= 0 || alpha >= 1 || !Number.isFinite(alpha)) + throw new Error('alpha must be in (0,1)'); + if (!Array.isArray(yDomain) || yDomain.length !== 2 || !yDomain.every(Number.isFinite)) + throw new Error('yDomain must be a [min, max] pair of numbers'); + + const d3 = await import('https://cdn.jsdelivr.net/npm/d3@7/+esm'); + + const buf = []; + let prevEma = undefined; + + for await (const p of stream) { + if (!p || !('timestamp' in p) || !('value' in p)) continue; + const v = Number(p.value); + if (!Number.isFinite(v)) continue; + + if (prevEma === undefined) prevEma = v; + else prevEma = alpha * v + (1 - alpha) * prevEma; + + buf.push({ timestamp: p.timestamp, value: v, ema: prevEma }); + if (buf.length > maxPoints) buf.shift(); + } + + const data = buf; + let path = ''; + + if (data.length) { + const xs = d3.scaleLinear() + .domain([data[0].timestamp, data[data.length - 1].timestamp]) + .range([0, width]); + + const ys = d3.scaleLinear() + .domain(yDomain) + .range([height, 0]); + + const line = d3.line() + .x(d => xs(d.timestamp)) + .y(d => ys(d.ema)); + + path = line(data) || ''; + } + + return { data, path }; +} +export default createStreamVisualizer; +// Generation time: 14.769s +// Result: PASS \ No newline at end of file