Feat: Read generation time from file comment

This commit is contained in:
2025-11-27 10:24:05 -08:00
parent 82aa65df97
commit dff5f0e37d

View File

@@ -106,17 +106,19 @@
const li=document.createElement('li');
li.className='flex items-center gap-3 text-sm';
list.appendChild(li);
const time=genTimes[model]?.[test];
if(time==null){
const entry=genTimes[model]?.[test];
if(entry==null){
li.innerHTML=`— <span class="font-medium text-gray-800">${test}</span><span class="mono text-gray-500 ml-auto">N/A</span>`;
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>`;
let status='✅';
const outUrl=`./tests/${test}/outputs/${sModel}.js`;
const srcP=fetch(outUrl).then(r=>r.text()).catch(()=>'');
try{
const testP=(async()=>{
const tMod=await import(`./tests/${test}/test.js`);
const lMod=await import(`./tests/${test}/outputs/${sModel}.js`);
const lMod=await import(outUrl);
await tMod.default.runTest(lMod.default);
})();
await Promise.race([testP,new Promise((_,r)=>setTimeout(()=>r(new Error('Timeout')),12000))]);
@@ -125,6 +127,9 @@
status='❌';
}
if(status==='✅')passed++;
const src=await srcP;
const fTime=src.match(/\/\/ Generation time: ([\d\.]+)s/)?.[1];
const time=fTime?parseFloat(fTime):(typeof entry==='number'?entry:null);
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>`;
}