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:
93
index.html
93
index.html
@@ -71,64 +71,71 @@
|
|||||||
</footer>
|
</footer>
|
||||||
</main>
|
</main>
|
||||||
<script type="module">
|
<script type="module">
|
||||||
const get = id => document.getElementById(id);
|
const get=id=>document.getElementById(id);
|
||||||
const container = get('results-container');
|
const container=get('results-container');
|
||||||
const updatedEl = get('last-updated');
|
const updatedEl=get('last-updated');
|
||||||
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 grades=[[.97,'A+'],[.93,'A'],[.9,'A-'],[.87,'B+'],[.83,'B'],[.8,'B-'],[.77,'C+'],[.73,'C'],[.7,'C-'],[.6,'D'],[0,'F']];
|
||||||
const run = async () => {
|
const gradeOf=ratio=>grades.find(([floor])=>ratio>=floor)[1];
|
||||||
const readme = await fetch('./README').then(r => r.text());
|
const run=async()=>{
|
||||||
const genTimes = await fetch('./results.json').then(r => r.json());
|
const readme=await fetch('./README').then(r=>r.text());
|
||||||
const models = readme.match(/<!-- MODELS_START -->\n([\s\S]+?)\n<!-- MODELS_END -->/)[1].trim().split('\n');
|
const genTimes=await fetch('./results.json').then(r=>r.json());
|
||||||
const tests = [...new Set(Object.values(genTimes).flatMap(Object.keys))].sort();
|
const models=readme.match(/<!-- MODELS_START -->\n([\s\S]+?)\n<!-- MODELS_END -->/)[1].trim().split('\n');
|
||||||
|
const tests=[...new Set(Object.values(genTimes).flatMap(Object.keys))].sort();
|
||||||
for (const model of models) {
|
for(const model of models){
|
||||||
const sModel = model.replace(/[\/:]/g, '_');
|
const sModel=model.replace(/[\/:]/g,'_');
|
||||||
const card = document.createElement('section');
|
const card=document.createElement('section');
|
||||||
card.className = 'rounded-2xl border border-gray-200 bg-white shadow-sm overflow-hidden';
|
card.className='rounded-2xl border border-gray-200 bg-white shadow-sm overflow-hidden';
|
||||||
card.innerHTML = `
|
card.innerHTML=`
|
||||||
<div class="bg-gray-50 px-5 py-3 border-b border-gray-200">
|
<div class="bg-gray-50 px-5 py-3 border-b border-gray-200">
|
||||||
<p class="mono text-sm text-gray-700 font-medium">${model}</p>
|
<p class="mono text-sm text-gray-700 font-medium">${model}</p>
|
||||||
</div>
|
</div>
|
||||||
<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 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';
|
||||||
list.appendChild(li);
|
list.appendChild(li);
|
||||||
const time = genTimes[model]?.[test];
|
const time=genTimes[model]?.[test];
|
||||||
|
if(time===null){
|
||||||
if (time === null) {
|
li.innerHTML=`— <span class="font-medium text-gray-800">${test}</span><span class="mono text-gray-500 ml-auto">N/A</span>`;
|
||||||
li.innerHTML = `— <span class="font-medium text-gray-800">${test}</span><span class="mono text-gray-500 ml-auto">N/A</span>`;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
li.innerHTML=`<svg class="animate-spin h-4 w-4 text-gray-400" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg><span class="font-medium text-gray-800">${test}</span><span class="mono text-gray-500 ml-auto">...</span>`;
|
||||||
li.innerHTML = `<svg class="animate-spin h-4 w-4 text-gray-400" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg><span class="font-medium text-gray-800">${test}</span><span class="mono text-gray-500 ml-auto">...</span>`;
|
let status='✅';
|
||||||
|
try{
|
||||||
let status = '✅';
|
const testP=(async()=>{
|
||||||
try {
|
const tMod=await import(`./tests/${test}/test.js`);
|
||||||
const testP = (async () => {
|
const lMod=await import(`./tests/${test}/outputs/${sModel}.js`);
|
||||||
const tMod = await import(`./tests/${test}/test.js`);
|
|
||||||
const lMod = await import(`./tests/${test}/outputs/${sModel}.js`);
|
|
||||||
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))]);
|
||||||
} catch (e) {
|
}catch(e){
|
||||||
console.error(`${model} - ${test}: `, e);
|
console.error(`${model} - ${test}: `,e);
|
||||||
status = '❌';
|
status='❌';
|
||||||
}
|
}
|
||||||
const timeStr = time?.toFixed(3) ?? 'N/A';
|
if(status==='✅')passed++;
|
||||||
li.innerHTML = `${status} <span class="font-medium text-gray-800">${test}</span><span class="mono text-gray-500 ml-auto">${timeStr}s</span>`;
|
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>`;
|
||||||
}
|
}
|
||||||
|
const ratio=tests.length?passed/tests.length:0;
|
||||||
|
const li=document.createElement('li');
|
||||||
|
li.className='mt-3 pt-3 border-t border-gray-200 flex items-center text-sm justify-between';
|
||||||
|
const grade=gradeOf(ratio);
|
||||||
|
li.innerHTML=`
|
||||||
|
<span class="text-gray-600">Score</span>
|
||||||
|
<span class="flex items-center gap-3">
|
||||||
|
<span class="mono text-gray-900 font-semibold">${passed}/${tests.length}</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>
|
||||||
|
</span>`;
|
||||||
|
list.appendChild(li);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
run();
|
run();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user