mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-13 16:17:54 +00:00
Fix: add per-model grade summary
This commit is contained in:
41
index.html
41
index.html
@@ -77,7 +77,8 @@
|
|||||||
const now=new Date();
|
const now=new Date();
|
||||||
updatedEl.textContent=now.toLocaleDateString('en-US',{month:'short',year:'numeric'});
|
updatedEl.textContent=now.toLocaleDateString('en-US',{month:'short',year:'numeric'});
|
||||||
updatedEl.dateTime=now.toISOString().split('T')[0];
|
updatedEl.dateTime=now.toISOString().split('T')[0];
|
||||||
const grade=p=>p>=.95?'A+':p>=.9?'A':p>=.85?'A-':p>=.75?'B+':p>=.65?'B':p>=.5?'B-':'C';
|
const grades=[[.97,'A+'],[.93,'A'],[.9,'A-'],[.87,'B+'],[.83,'B'],[.8,'B-'],[.77,'C+'],[.73,'C'],[.7,'C-'],[.6,'D'],[0,'F']];
|
||||||
|
const gradeOf=ratio=>grades.find(([floor])=>ratio>=floor)[1];
|
||||||
const run=async()=>{
|
const run=async()=>{
|
||||||
const readme=await fetch('./README').then(r=>r.text());
|
const readme=await fetch('./README').then(r=>r.text());
|
||||||
const genTimes=await fetch('./results.json').then(r=>r.json());
|
const genTimes=await fetch('./results.json').then(r=>r.json());
|
||||||
@@ -94,7 +95,7 @@
|
|||||||
<ul class="p-4 space-y-2" id="list-${sModel}"></ul>`;
|
<ul class="p-4 space-y-2" id="list-${sModel}"></ul>`;
|
||||||
container.appendChild(card);
|
container.appendChild(card);
|
||||||
const list=get(`list-${sModel}`);
|
const list=get(`list-${sModel}`);
|
||||||
let pass=0,fail=0;
|
let passed=0;
|
||||||
for(const test of tests){
|
for(const test of tests){
|
||||||
const li=document.createElement('li');
|
const li=document.createElement('li');
|
||||||
li.className='flex items-center gap-3 text-sm';
|
li.className='flex items-center gap-3 text-sm';
|
||||||
@@ -113,37 +114,25 @@
|
|||||||
await tMod.default.runTest(lMod.default);
|
await tMod.default.runTest(lMod.default);
|
||||||
})();
|
})();
|
||||||
await Promise.race([testP,new Promise((_,r)=>setTimeout(()=>r(new Error('Timeout')),12000))]);
|
await Promise.race([testP,new Promise((_,r)=>setTimeout(()=>r(new Error('Timeout')),12000))]);
|
||||||
pass++;
|
|
||||||
}catch(e){
|
}catch(e){
|
||||||
console.error(`${model} - ${test}: `,e);
|
console.error(`${model} - ${test}: `,e);
|
||||||
status='❌';
|
status='❌';
|
||||||
fail++;
|
|
||||||
}
|
}
|
||||||
|
if(status==='✅')passed++;
|
||||||
const timeStr=time?.toFixed(3)??'N/A';
|
const timeStr=time?.toFixed(3)??'N/A';
|
||||||
li.innerHTML=`${status} <span class="font-medium text-gray-800">${test}</span><span class="mono text-gray-500 ml-auto">${timeStr}s</span>`;
|
li.innerHTML=`${status} <span class="font-medium text-gray-800">${test}</span><span class="mono text-gray-500 ml-auto">${timeStr}s</span>`;
|
||||||
}
|
}
|
||||||
const total=pass+fail;
|
const ratio=tests.length?passed/tests.length:0;
|
||||||
const pct=total?pass/total:0;
|
const li=document.createElement('li');
|
||||||
const summary=document.createElement('li');
|
li.className='mt-3 pt-3 border-t border-gray-200 flex items-center text-sm justify-between';
|
||||||
summary.className='pt-4 border-t border-gray-100 mt-4';
|
const grade=gradeOf(ratio);
|
||||||
summary.innerHTML=`
|
li.innerHTML=`
|
||||||
<div class="p-4 rounded-xl bg-gradient-to-r from-indigo-50 via-white to-emerald-50 border border-indigo-100 shadow-inner flex flex-col gap-3">
|
<span class="text-gray-600">Score</span>
|
||||||
<div class="flex items-center text-xs font-semibold uppercase tracking-wide text-gray-500">
|
<span class="flex items-center gap-3">
|
||||||
Performance Summary
|
<span class="mono text-gray-900 font-semibold">${passed}/${tests.length}</span>
|
||||||
<span class="mono text-gray-400 ml-auto">${total} tests</span>
|
<span class="inline-flex items-center rounded-full bg-gray-100 px-2 py-0.5 text-xs font-semibold text-gray-800">${grade}</span>
|
||||||
</div>
|
</span>`;
|
||||||
<div class="flex items-center gap-4">
|
list.appendChild(li);
|
||||||
<div class="flex-1">
|
|
||||||
<p class="text-sm text-gray-600">Right / Wrong</p>
|
|
||||||
<p class="text-lg font-semibold text-gray-900">${pass} / ${fail}</p>
|
|
||||||
</div>
|
|
||||||
<div class="flex flex-col items-end">
|
|
||||||
<p class="text-sm text-gray-600">Grade</p>
|
|
||||||
<span class="text-2xl font-bold text-indigo-600">${grade(pct)}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>`;
|
|
||||||
list.appendChild(summary);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
run();
|
run();
|
||||||
|
|||||||
Reference in New Issue
Block a user