mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-03-17 03:11:01 +00:00
Docs: Update benchmark for minimax/minimax-m2.5
This commit is contained in:
10
tests/10_scrypt_hash/outputs/minimax_minimax-m2.5.js
Normal file
10
tests/10_scrypt_hash/outputs/minimax_minimax-m2.5.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
async function hashPassword(pwd,salt){
|
||||||
|
const{scrypt}=await import('https://cdn.skypack.dev/scrypt-js');
|
||||||
|
const pw=new TextEncoder().encode(pwd);
|
||||||
|
const st=new TextEncoder().encode(salt);
|
||||||
|
const h=await scrypt(pw,st,1024,8,1,32);
|
||||||
|
return Array.from(h).map(b=>b.toString(16).padStart(2,'0')).join('');
|
||||||
|
}
|
||||||
|
export default hashPassword;
|
||||||
|
// Generation time: 30.558s
|
||||||
|
// Result: PASS
|
||||||
8
tests/11_geospatial/outputs/minimax_minimax-m2.5.js
Normal file
8
tests/11_geospatial/outputs/minimax_minimax-m2.5.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
async function analyzeGPS(readings, boundary) {
|
||||||
|
const{booleanPointInPolygon,point,lineString,length}=await import('https://cdn.jsdelivr.net/npm/@turf/turf@6/+esm');
|
||||||
|
const v=readings.filter(r=>booleanPointInPolygon(point(r.loc),boundary)).sort((a,b)=>a.ts-b.ts);
|
||||||
|
return v.length<2?0:Math.round(length(lineString(v.map(r=>r.loc)),{units:'kilometers'})*100)/100;
|
||||||
|
}
|
||||||
|
export default analyzeGPS;
|
||||||
|
// Generation time: 45.041s
|
||||||
|
// Result: PASS
|
||||||
36
tests/12_mst_pipeline/outputs/minimax_minimax-m2.5.js
Normal file
36
tests/12_mst_pipeline/outputs/minimax_minimax-m2.5.js
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
async function computeMST(toml) {
|
||||||
|
const { parse } = await import('https://esm.sh/smol-toml');
|
||||||
|
const { Heap } = await import('https://esm.sh/mnemonist');
|
||||||
|
const tbl = (await import('https://esm.sh/text-table')).default;
|
||||||
|
const { edges = [] } = parse(toml);
|
||||||
|
const h = new Heap((a, b) => a.weight - b.weight);
|
||||||
|
edges.forEach(e => h.push(e));
|
||||||
|
const nodes = new Set();
|
||||||
|
edges.forEach(e => { nodes.add(e.from); nodes.add(e.to); });
|
||||||
|
const arr = [...nodes], N = arr.length, id = Object.fromEntries(arr.map((n, i) => [n, i]));
|
||||||
|
const p = new Int32Array(N), r = new Uint8Array(N);
|
||||||
|
for (let i = 0; i < N; i++) p[i] = i;
|
||||||
|
const find = x => p[x] === x ? x : p[x] = find(p[x]);
|
||||||
|
const union = (x, y) => {
|
||||||
|
let u = find(x), v = find(y);
|
||||||
|
if (u === v) return false;
|
||||||
|
if (r[u] < r[v]) p[u] = v;
|
||||||
|
else if (r[u] > r[v]) p[v] = u;
|
||||||
|
else { p[v] = u; r[u]++; }
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
const mst = [];
|
||||||
|
let tw = 0;
|
||||||
|
while (h.size && mst.length < N - 1) {
|
||||||
|
const e = h.pop();
|
||||||
|
if (union(id[e.from], id[e.to])) {
|
||||||
|
mst.push([e.from, e.to, String(e.weight)]);
|
||||||
|
tw += e.weight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const rows = [['From', 'To', 'Weight'], ...mst];
|
||||||
|
return { table: tbl(rows, { align: ['l', 'l', 'r'] }), totalWeight: tw };
|
||||||
|
}
|
||||||
|
export default computeMST;
|
||||||
|
// Generation time: 86.373s
|
||||||
|
// Result: PASS
|
||||||
32
tests/1_dijkstra/outputs/minimax_minimax-m2.5.js
Normal file
32
tests/1_dijkstra/outputs/minimax_minimax-m2.5.js
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
async function findShortestPath(graph, start, end) {
|
||||||
|
if (!(start in graph) || !(end in graph)) return Infinity;
|
||||||
|
if (start === end) return 0;
|
||||||
|
|
||||||
|
const { default: PriorityQueue } = await import('https://cdn.skypack.dev/js-priority-queue');
|
||||||
|
|
||||||
|
const pq = new PriorityQueue({ comparator: (a, b) => a.w - b.w });
|
||||||
|
const dist = {};
|
||||||
|
|
||||||
|
for (const n in graph) dist[n] = Infinity;
|
||||||
|
dist[start] = 0;
|
||||||
|
pq.queue({ n: start, w: 0 });
|
||||||
|
|
||||||
|
while (pq.length) {
|
||||||
|
const { n, w } = pq.dequeue();
|
||||||
|
if (w !== dist[n]) continue;
|
||||||
|
if (n === end) return w;
|
||||||
|
|
||||||
|
for (const [nb, wgt] of Object.entries(graph[n] || {})) {
|
||||||
|
const ndist = w + wgt;
|
||||||
|
if (ndist < dist[nb]) {
|
||||||
|
dist[nb] = ndist;
|
||||||
|
pq.queue({ n: nb, w: ndist });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Infinity;
|
||||||
|
}
|
||||||
|
export default findShortestPath;
|
||||||
|
// Generation time: 64.656s
|
||||||
|
// Result: PASS
|
||||||
22
tests/2_convex_hull/outputs/minimax_minimax-m2.5.js
Normal file
22
tests/2_convex_hull/outputs/minimax_minimax-m2.5.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
async function findConvexHull(points) {
|
||||||
|
const _ = (await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.min.js')).default;
|
||||||
|
const pts = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y']);
|
||||||
|
if (pts.length <= 2) 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 > 1 && 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 > 1 && 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: 58.750s
|
||||||
|
// Result: PASS
|
||||||
12
tests/3_lis/outputs/minimax_minimax-m2.5.js
Normal file
12
tests/3_lis/outputs/minimax_minimax-m2.5.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
async function findLISLength(arr) {
|
||||||
|
const { bisectLeft } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm');
|
||||||
|
const tails = [];
|
||||||
|
for (const v of arr) {
|
||||||
|
const i = bisectLeft(tails, v);
|
||||||
|
i === tails.length ? tails.push(v) : (tails[i] = v);
|
||||||
|
}
|
||||||
|
return tails.length;
|
||||||
|
}
|
||||||
|
export default findLISLength;
|
||||||
|
// Generation time: 22.716s
|
||||||
|
// Result: PASS
|
||||||
7
tests/4_transpiler/outputs/minimax_minimax-m2.5.js
Normal file
7
tests/4_transpiler/outputs/minimax_minimax-m2.5.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
async function renderTemplate(template, data = {}) {
|
||||||
|
const { default: Handlebars } = await import('https://esm.sh/handlebars');
|
||||||
|
return Handlebars.compile(template)(data);
|
||||||
|
}
|
||||||
|
export default renderTemplate;
|
||||||
|
// Generation time: 23.189s
|
||||||
|
// Result: PASS
|
||||||
7
tests/5_markdown_parser/outputs/minimax_minimax-m2.5.js
Normal file
7
tests/5_markdown_parser/outputs/minimax_minimax-m2.5.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
async function parseMarkdown(md) {
|
||||||
|
const { default: M } = await import('https://cdn.jsdelivr.net/npm/marked/lib/marked.esm.js');
|
||||||
|
return M.parse(md);
|
||||||
|
}
|
||||||
|
export default parseMarkdown;
|
||||||
|
// Generation time: 41.642s
|
||||||
|
// Result: FAIL
|
||||||
23
tests/6_csv_processor/outputs/minimax_minimax-m2.5.js
Normal file
23
tests/6_csv_processor/outputs/minimax_minimax-m2.5.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
async function processCSV(csv, { filterColumn, filterValue, groupBy, aggregateColumn, operation }) {
|
||||||
|
const { default: Papa } = await import('https://cdn.jsdelivr.net/npm/papaparse@5.4.1/+esm');
|
||||||
|
const { data } = Papa.parse(csv, { header: true });
|
||||||
|
const groups = {};
|
||||||
|
for (const row of data) {
|
||||||
|
if (row[filterColumn] == filterValue) {
|
||||||
|
const key = row[groupBy];
|
||||||
|
(groups[key] ??= []).push(row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Object.entries(groups).map(([key, rows]) => {
|
||||||
|
const result = operation === 'count'
|
||||||
|
? rows.length
|
||||||
|
: (() => {
|
||||||
|
const sum = rows.reduce((acc, r) => acc + (Number(r[aggregateColumn]) || 0), 0);
|
||||||
|
return operation === 'sum' ? sum : sum / rows.length;
|
||||||
|
})();
|
||||||
|
return { [groupBy]: key, result };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
export default processCSV;
|
||||||
|
// Generation time: 58.093s
|
||||||
|
// Result: PASS
|
||||||
38
tests/7_scheduler/outputs/minimax_minimax-m2.5.js
Normal file
38
tests/7_scheduler/outputs/minimax_minimax-m2.5.js
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
async function findAvailableSlots(A,B,C){
|
||||||
|
const D=(await import('https://cdn.jsdelivr.net/npm/dayjs@1.11.7/dayjs.esm.min.js')).default;
|
||||||
|
const E=D.utc;
|
||||||
|
const F=[...A,...B].sort((a,b)=>E(a.start).diff(E(b.start)));
|
||||||
|
const G=[];
|
||||||
|
for(const{start:s,end:e}of F){
|
||||||
|
const S=E(s),E0=E(e);
|
||||||
|
if(!G.length||S.isAfter(G[G.length-1].e))G.push({s:S,e:E0});
|
||||||
|
else if(E0.isAfter(G[G.length-1].e))G[G.length-1].e=E0;
|
||||||
|
}
|
||||||
|
const{durationMinutes:d,searchRange:{start:S0,end:E1},workHours:{start:wS,end:wE}}=C;
|
||||||
|
const T=t=>+t.slice(0,2)*60+ +t.slice(3);
|
||||||
|
const wSmin=T(wS),wEmin=T(wE);
|
||||||
|
const S=E(S0),En=E(E1);
|
||||||
|
const R=[];
|
||||||
|
let cur=S;
|
||||||
|
for(const{s:b,e:ee}of G){
|
||||||
|
if(b.isAfter(cur)&&b.isBefore(En))R.push({s:cur,e:b});
|
||||||
|
if(ee.isAfter(cur))cur=ee;
|
||||||
|
if(cur.isSame(En)||cur.isAfter(En))break;
|
||||||
|
}
|
||||||
|
if(cur.isBefore(En))R.push({s:cur,e:En});
|
||||||
|
const O=[];
|
||||||
|
for(const{s:f,e:g}of R){
|
||||||
|
let x=f;
|
||||||
|
while(true){
|
||||||
|
const y=x.add(d,'minute');
|
||||||
|
if(y.isAfter(g))break;
|
||||||
|
const m1=x.hour()*60+x.minute(),m2=y.hour()*60+y.minute();
|
||||||
|
if(m1>=wSmin&&m2<=wEmin)O.push({start:x.toISO(),end:y.toISO()});
|
||||||
|
x=y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return O;
|
||||||
|
}
|
||||||
|
export default findAvailableSlots;
|
||||||
|
// Generation time: 175.444s
|
||||||
|
// Result: FAIL
|
||||||
14
tests/8_json_validator/outputs/minimax_minimax-m2.5.js
Normal file
14
tests/8_json_validator/outputs/minimax_minimax-m2.5.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
async function validateJSON(data, schema) {
|
||||||
|
try {
|
||||||
|
const { default: Ajv } = await import('https://esm.sh/ajv@8');
|
||||||
|
const ajv = new Ajv({ allErrors: true, strict: false });
|
||||||
|
const validate = ajv.compile(schema);
|
||||||
|
const valid = validate(data);
|
||||||
|
return { valid, errors: valid ? [] : validate.errors.map(e => e.message) };
|
||||||
|
} catch (e) {
|
||||||
|
return { valid: false, errors: [e.message] };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default validateJSON;
|
||||||
|
// Generation time: 35.988s
|
||||||
|
// Result: PASS
|
||||||
19
tests/9_stream_visualizer/outputs/minimax_minimax-m2.5.js
Normal file
19
tests/9_stream_visualizer/outputs/minimax_minimax-m2.5.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
export async function createStreamVisualizer(asyncIterable, options) {
|
||||||
|
const { maxPoints = 1000, alpha = 0.1, width = 800, height = 400, yDomain = [0, 100] } = options || {};
|
||||||
|
const d3 = await import('d3');
|
||||||
|
const data = [];
|
||||||
|
let prevEma;
|
||||||
|
for await (const { timestamp, value } of asyncIterable) {
|
||||||
|
prevEma = prevEma === undefined ? value : alpha * value + (1 - alpha) * prevEma;
|
||||||
|
data.push({ timestamp, value, ema: prevEma });
|
||||||
|
if (data.length > maxPoints) data.shift();
|
||||||
|
}
|
||||||
|
if (!data.length) return { data: [], path: '' };
|
||||||
|
const x = d3.scaleLinear().domain([data[0].timestamp, data[data.length - 1].timestamp]).range([0, width]);
|
||||||
|
const y = d3.scaleLinear().domain(yDomain).range([height, 0]);
|
||||||
|
const path = d3.line().x(d => x(d.timestamp)).y(d => y(d.ema))(data) || '';
|
||||||
|
return { data, path };
|
||||||
|
}
|
||||||
|
export default createStreamVisualizer;
|
||||||
|
// Generation time: 53.348s
|
||||||
|
// Result: FAIL
|
||||||
Reference in New Issue
Block a user