mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-07-18 05:45:46 +00:00
Compare commits
2 Commits
48dfa6cd44
...
0d119317eb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d119317eb | ||
| 866e5c2bbb |
7
README
7
README
@@ -9,6 +9,7 @@ SHARED_PROMPT: "Provide production-ready and maintainable JavaScript code. Apply
|
||||
The following models are included in the benchmark run.
|
||||
|
||||
<!-- MODELS_START -->
|
||||
x-ai/grok-4.5
|
||||
anthropic/claude-sonnet-5 EFF:high
|
||||
z-ai/glm-5.2
|
||||
moonshotai/kimi-k2.7-code
|
||||
@@ -17,15 +18,9 @@ anthropic/claude-opus-4.8 EFF:medium
|
||||
google/gemini-3.5-flash
|
||||
google/gemini-3.1-flash-lite
|
||||
openai/gpt-5.5 EFF:high
|
||||
deepseek/deepseek-v4-pro
|
||||
moonshotai/kimi-k2.6
|
||||
anthropic/claude-opus-4.7 EFF:medium
|
||||
z-ai/glm-5.1
|
||||
openai/gpt-5.4
|
||||
openai/gpt-5.3-codex
|
||||
google/gemini-3.1-pro-preview
|
||||
anthropic/claude-opus-4.6
|
||||
moonshotai/kimi-k2.5
|
||||
google/gemini-3-flash-preview TEMP:0.35
|
||||
deepseek/deepseek-v3.2
|
||||
<!-- MODELS_END -->
|
||||
|
||||
10
tests/10_scrypt_hash/outputs/x-ai_grok-4.5.js
Normal file
10
tests/10_scrypt_hash/outputs/x-ai_grok-4.5.js
Normal file
@@ -0,0 +1,10 @@
|
||||
async function hashPassword(password,salt){
|
||||
const{default:scrypt}=await import("https://esm.sh/scrypt-js@3.0.1");
|
||||
const enc=new TextEncoder;
|
||||
const p=enc.encode(password),s=enc.encode(salt);
|
||||
const hash=await scrypt(p,s,1024,8,1,32);
|
||||
return Array.from(hash).map(b=>b.toString(16).padStart(2,"0")).join("")
|
||||
}
|
||||
export default hashPassword;
|
||||
// Generation time: 22.963s
|
||||
// Result: FAIL
|
||||
9
tests/11_geospatial/outputs/x-ai_grok-4.5.js
Normal file
9
tests/11_geospatial/outputs/x-ai_grok-4.5.js
Normal file
@@ -0,0 +1,9 @@
|
||||
async function analyzeGPS(readings,boundary){
|
||||
const{booleanPointInPolygon:i,lineString:l,length:e}=await import('https://esm.sh/@turf/turf@7.1.0');
|
||||
const v=readings.filter(r=>i(r.loc,boundary,{ignoreBoundary:true})).sort((a,b)=>a.ts-b.ts);
|
||||
if(v.length<2)return 0;
|
||||
return+e(l(v.map(r=>r.loc)),{units:'kilometers'}).toFixed(2)
|
||||
}
|
||||
export default analyzeGPS;
|
||||
// Generation time: 14.349s
|
||||
// Result: PASS
|
||||
36
tests/12_mst_pipeline/outputs/x-ai_grok-4.5.js
Normal file
36
tests/12_mst_pipeline/outputs/x-ai_grok-4.5.js
Normal file
@@ -0,0 +1,36 @@
|
||||
async function computeMST(t){
|
||||
const[{parse},H,{default:tt}]=await Promise.all([
|
||||
import('https://esm.sh/smol-toml@1.3.1'),
|
||||
import('https://esm.sh/mnemonist@0.39.8/heap'),
|
||||
import('https://esm.sh/text-table@0.2.0')
|
||||
]);
|
||||
const Heap=H.default;
|
||||
const d=parse(t);
|
||||
const es=d.edges||[];
|
||||
const ns=new Set;
|
||||
for(const e of es){ns.add(e.from);ns.add(e.to)}
|
||||
const n=ns.size;
|
||||
const h=new Heap((a,b)=>a.weight-b.weight);
|
||||
for(const e of es)h.push(e);
|
||||
const p={},r={};
|
||||
for(const x of ns){p[x]=x;r[x]=0}
|
||||
const f=x=>{if(p[x]!==x)p[x]=f(p[x]);return p[x]};
|
||||
const u=(x,y)=>{
|
||||
const px=f(x),py=f(y);
|
||||
if(px===py)return!1;
|
||||
if(r[px]<r[py])p[px]=py;
|
||||
else if(r[px]>r[py])p[py]=px;
|
||||
else{p[py]=px;r[px]++}
|
||||
return!0
|
||||
};
|
||||
const m=[];
|
||||
let w=0;
|
||||
while(m.length<n-1&&h.size){
|
||||
const e=h.pop();
|
||||
if(u(e.from,e.to)){m.push([e.from,e.to,String(e.weight)]);w+=e.weight}
|
||||
}
|
||||
return{table:tt([['From','To','Weight'],...m]),totalWeight:w}
|
||||
}
|
||||
export default computeMST;
|
||||
// Generation time: 15.793s
|
||||
// Result: PASS
|
||||
26
tests/1_dijkstra/outputs/x-ai_grok-4.5.js
Normal file
26
tests/1_dijkstra/outputs/x-ai_grok-4.5.js
Normal file
@@ -0,0 +1,26 @@
|
||||
async function findShortestPath(graph, start, end) {
|
||||
const { default: PriorityQueue } = await import('https://esm.sh/js-priority-queue');
|
||||
const dist = {};
|
||||
for (const node of Object.keys(graph)) dist[node] = Infinity;
|
||||
dist[start] = 0;
|
||||
const pq = new PriorityQueue({ comparator: (a, b) => a[1] - b[1] });
|
||||
pq.queue([start, 0]);
|
||||
const visited = new Set();
|
||||
while (pq.length) {
|
||||
const [u, cost] = pq.dequeue();
|
||||
if (visited.has(u)) continue;
|
||||
visited.add(u);
|
||||
if (u === end) return cost;
|
||||
for (const [v, weight] of Object.entries(graph[u] || {})) {
|
||||
const alt = cost + weight;
|
||||
if (alt < (dist[v] ?? Infinity)) {
|
||||
dist[v] = alt;
|
||||
pq.queue([v, alt]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Infinity;
|
||||
}
|
||||
export default findShortestPath;
|
||||
// Generation time: 22.841s
|
||||
// Result: PASS
|
||||
22
tests/2_convex_hull/outputs/x-ai_grok-4.5.js
Normal file
22
tests/2_convex_hull/outputs/x-ai_grok-4.5.js
Normal file
@@ -0,0 +1,22 @@
|
||||
async function findConvexHull(points){
|
||||
const{sortBy,uniqWith}=await import("https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/+esm");
|
||||
points=uniqWith(points,(a,b)=>a.x===b.x&&a.y===b.y);
|
||||
points=sortBy(points,["x","y"]);
|
||||
if(points.length<=2)return points;
|
||||
const cross=(o,a,b)=>(a.x-o.x)*(b.y-o.y)-(a.y-o.y)*(b.x-o.x);
|
||||
let lower=[];
|
||||
for(const p of points){
|
||||
while(lower.length>=2&&cross(lower.at(-2),lower.at(-1),p)<=0)lower.pop();
|
||||
lower.push(p);
|
||||
}
|
||||
let upper=[];
|
||||
for(let i=points.length-1;i>=0;i--){
|
||||
const p=points[i];
|
||||
while(upper.length>=2&&cross(upper.at(-2),upper.at(-1),p)<=0)upper.pop();
|
||||
upper.push(p);
|
||||
}
|
||||
return lower.slice(0,-1).concat(upper.slice(0,-1));
|
||||
}
|
||||
export default findConvexHull;
|
||||
// Generation time: 37.988s
|
||||
// Result: PASS
|
||||
26
tests/3_signal_pipeline/outputs/x-ai_grok-4.5.js
Normal file
26
tests/3_signal_pipeline/outputs/x-ai_grok-4.5.js
Normal file
@@ -0,0 +1,26 @@
|
||||
async function analyzeSignal(y){
|
||||
const[m1,m2,m3,m4,m5]=await Promise.all([
|
||||
import('https://esm.sh/js-yaml'),
|
||||
import('https://esm.sh/mathjs'),
|
||||
import('https://esm.sh/ndarray'),
|
||||
import('https://esm.sh/ndarray-fft'),
|
||||
import('https://esm.sh/dompurify')
|
||||
]);
|
||||
const yaml=m1.default,math=m2.default,nd=m3.default,fft=m4.default,DP=m5.default;
|
||||
const c=yaml.load(y),{sampleRate:sr,duration:d,components:cs}=c,N=sr*d;
|
||||
const s=Array.from({length:N},(_,i)=>cs.reduce((a,{frequency:f,amplitude:A})=>a+A*math.sin(2*math.pi*f*i/sr),0));
|
||||
const re=nd(s),im=nd(new Float64Array(N));
|
||||
fft(1,re,im);
|
||||
const mag=[],h=N/2;
|
||||
for(let k=0;k<=h;k++)mag[k]=math.sqrt(re.get(k)**2+im.get(k)**2)/h;
|
||||
const peaks=[];
|
||||
for(let k=0;k<=h;k++)if(mag[k]>0.1)peaks.push({frequencyHz:Math.round(k*sr/N),magnitude:+mag[k].toFixed(2)});
|
||||
peaks.sort((a,b)=>b.magnitude-a.magnitude);
|
||||
let htm='<table><tr><th>Frequency (Hz)</th><th>Magnitude</th></tr>';
|
||||
for(const p of peaks)htm+=`<tr><td>${p.frequencyHz}</td><td>${p.magnitude}</td></tr>`;
|
||||
htm+='</table>';
|
||||
return{peaks,html:DP.sanitize(htm),signalLength:N}
|
||||
}
|
||||
export default analyzeSignal;
|
||||
// Generation time: 30.792s
|
||||
// Result: FAIL
|
||||
23
tests/4_hexchain_pipeline/outputs/x-ai_grok-4.5.js
Normal file
23
tests/4_hexchain_pipeline/outputs/x-ai_grok-4.5.js
Normal file
@@ -0,0 +1,23 @@
|
||||
async function hexchain(t){
|
||||
const[{parse},sr,ss,Ajv,tt,DP]=await Promise.all([
|
||||
import('https://esm.sh/smol-toml'),
|
||||
import('https://esm.sh/seedrandom').then(m=>m.default),
|
||||
import('https://esm.sh/simple-statistics'),
|
||||
import('https://esm.sh/ajv').then(m=>m.default),
|
||||
import('https://esm.sh/text-table').then(m=>m.default),
|
||||
import('https://esm.sh/dompurify').then(m=>m.default)
|
||||
]);
|
||||
const c=parse(t);
|
||||
const a=new Ajv();
|
||||
const s={type:'object',required:['seed','count','label'],properties:{seed:{type:'string'},count:{type:'integer',minimum:1,maximum:10000},label:{type:'string',minLength:1}}};
|
||||
if(!a.validate(s,c))return{valid:false,errors:a.errorsText()};
|
||||
const r=sr(c.seed),n=[];
|
||||
for(let i=0;i<c.count;i++)n.push(r());
|
||||
const mean=+ss.mean(n).toFixed(6),stddev=+ss.standardDeviation(n).toFixed(6),median=+ss.median(n).toFixed(6);
|
||||
const tab=tt([['Stat','Value'],['mean',String(mean)],['stddev',String(stddev)],['median',String(median)]]);
|
||||
const html=DP.sanitize(`<pre class="stats">${tab}</pre>`);
|
||||
return{valid:true,label:c.label,stats:{mean,stddev,median},table:html,count:c.count};
|
||||
}
|
||||
export default hexchain;
|
||||
// Generation time: 6.554s
|
||||
// Result: PASS
|
||||
7
tests/5_markdown_parser/outputs/x-ai_grok-4.5.js
Normal file
7
tests/5_markdown_parser/outputs/x-ai_grok-4.5.js
Normal file
@@ -0,0 +1,7 @@
|
||||
async function parseMarkdown(s){
|
||||
const{marked}=await import('https://cdn.jsdelivr.net/npm/marked@13.0.3/lib/marked.esm.js')
|
||||
return marked.parse(s)
|
||||
}
|
||||
export default parseMarkdown;
|
||||
// Generation time: 6.585s
|
||||
// Result: PASS
|
||||
4
tests/6_csv_processor/outputs/x-ai_grok-4.5.js
Normal file
4
tests/6_csv_processor/outputs/x-ai_grok-4.5.js
Normal file
@@ -0,0 +1,4 @@
|
||||
async function processCSV(c,g){const{filterColumn:f,filterValue:v,groupBy:b,aggregateColumn:a,operation:o}=g;const P=(await import('https://esm.sh/papaparse')).default;const L=(await import('https://esm.sh/lodash')).default;const{data:d}=P.parse(c,{header:1,skipEmptyLines:1});const r=L.filter(d,x=>x[f]==v);const m=L.groupBy(r,b);return Object.entries(m).map(([k,s])=>{let e;if(o=='count')e=s.length;else{const n=s.map(x=>{const t=+x[a];return isNaN(t)?0:t});const u=n.reduce((p,q)=>p+q,0);e=o=='sum'?u:u/n.length}return{[b]:k,result:e}})}
|
||||
export default processCSV;
|
||||
// Generation time: 17.149s
|
||||
// Result: PASS
|
||||
50
tests/7_scheduler/outputs/x-ai_grok-4.5.js
Normal file
50
tests/7_scheduler/outputs/x-ai_grok-4.5.js
Normal file
@@ -0,0 +1,50 @@
|
||||
async function findAvailableSlots(c1,c2,ct){
|
||||
const{DateTime:D,Interval:I}=await import('https://cdn.jsdelivr.net/npm/luxon@3.4.4/+esm');
|
||||
const p=s=>D.fromISO(s,{zone:'utc'});
|
||||
const{durationMinutes:dm,searchRange:{start:rss,end:ree},workHours:{start:wss,end:wee}}=ct;
|
||||
const rS=p(rss),rE=p(ree);
|
||||
const[wh,wm]=wss.split(':').map(Number),[eh,em]=wee.split(':').map(Number);
|
||||
let bs=[];
|
||||
for(const c of[c1,c2])for(const s of c)bs.push(I.fromDateTimes(p(s.start),p(s.end)));
|
||||
bs.sort((a,b)=>a.start-b.start);
|
||||
const mg=[];
|
||||
for(const iv of bs){
|
||||
if(!mg.length||mg[mg.length-1].end<iv.start)mg.push(iv);
|
||||
else{const l=mg[mg.length-1];mg[mg.length-1]=I.fromDateTimes(l.start,D.max(l.end,iv.end));}
|
||||
}
|
||||
const fs=[];
|
||||
let cur=rS;
|
||||
for(const b of mg){
|
||||
if(b.end<=cur)continue;
|
||||
if(b.start>cur){const fe=D.min(b.start,rE);if(fe>cur)fs.push(I.fromDateTimes(cur,fe));}
|
||||
cur=D.max(cur,b.end);if(cur>=rE)break;
|
||||
}
|
||||
if(cur<rE)fs.push(I.fromDateTimes(cur,rE));
|
||||
const ws=[];
|
||||
let dy=rS.startOf('day');
|
||||
const ld=rE.startOf('day');
|
||||
while(dy<=ld){
|
||||
const wS=dy.set({hour:wh,minute:wm,second:0,millisecond:0});
|
||||
const wE=dy.set({hour:eh,minute:em,second:0,millisecond:0});
|
||||
const wi=I.fromDateTimes(wS,wE).intersection(I.fromDateTimes(rS,rE));
|
||||
if(wi&&!wi.isEmpty())ws.push(wi);
|
||||
dy=dy.plus({days:1});
|
||||
}
|
||||
const av=[];
|
||||
for(const f of fs)for(const w of ws){const i=f.intersection(w);if(i&&!i.isEmpty())av.push(i);}
|
||||
av.sort((a,b)=>a.start-b.start);
|
||||
const sl=[];
|
||||
for(const a of av){
|
||||
let st=a.start;
|
||||
for(;;){
|
||||
const en=st.plus({minutes:dm});
|
||||
if(en>a.end)break;
|
||||
sl.push({start:st.toISO(),end:en.toISO()});
|
||||
st=en;
|
||||
}
|
||||
}
|
||||
return sl;
|
||||
}
|
||||
export default findAvailableSlots;
|
||||
// Generation time: 44.730s
|
||||
// Result: PASS
|
||||
10
tests/8_json_validator/outputs/x-ai_grok-4.5.js
Normal file
10
tests/8_json_validator/outputs/x-ai_grok-4.5.js
Normal file
@@ -0,0 +1,10 @@
|
||||
async function validateJSON(data,schema){
|
||||
const{default:Ajv}=await import("https://esm.sh/ajv@8");
|
||||
const ajv=new Ajv({allErrors:true});
|
||||
const validate=ajv.compile(schema);
|
||||
const valid=validate(data);
|
||||
return{valid,errors:valid?[]:validate.errors.map(e=>(e.instancePath+" "+e.message).trim())}
|
||||
}
|
||||
export default validateJSON;
|
||||
// Generation time: 13.050s
|
||||
// Result: PASS
|
||||
19
tests/9_stream_visualizer/outputs/x-ai_grok-4.5.js
Normal file
19
tests/9_stream_visualizer/outputs/x-ai_grok-4.5.js
Normal file
@@ -0,0 +1,19 @@
|
||||
async function createStreamVisualizer(asyncIterable,{maxPoints,alpha,width,height,yDomain}){
|
||||
const d3=await import('https://cdn.jsdelivr.net/npm/d3@7/+esm');
|
||||
const data=[];
|
||||
let p;
|
||||
for await(const{timestamp:t,value:v}of asyncIterable){
|
||||
const e=p==null?v:alpha*v+(1-alpha)*p;
|
||||
p=e;
|
||||
data.push({timestamp:t,value:v,ema:e});
|
||||
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: 7.991s
|
||||
// Result: PASS
|
||||
Reference in New Issue
Block a user