Lynchmark
-
+
Last updated
@@ -85,11 +85,15 @@
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 gradeOf=ratio=>grades.find(([floor])=>ratio>=floor)[1];
+
const run=async()=>{
const readme=await fetch('./README').then(r=>r.text());
- const genTimes=await fetch('./results.json').then(r=>r.json());
const models=readme.match(/\n([\s\S]+?)\n/)[1].trim().split('\n');
- const tests=[...new Set(Object.values(genTimes).flatMap(Object.keys))].sort();
+
+ const testsRes=await fetch('https://api.github.com/repos/multipleof4/lynchmark/contents/tests');
+ const testsData=await testsRes.json();
+ const tests=testsData.filter(d=>d.type==='dir').map(d=>d.name).sort();
+
for(const model of models){
const sModel=model.replace(/[\/:]/g,'_');
const card=document.createElement('section');
@@ -102,19 +106,29 @@
container.appendChild(card);
const list=get(`list-${sModel}`);
let passed=0;
+ let ran=0;
+
for(const test of tests){
const li=document.createElement('li');
li.className='flex items-center gap-3 text-sm';
list.appendChild(li);
- const entry=genTimes[model]?.[test];
- if(entry==null){
- li.innerHTML=`— ${test}N/A`;
- continue;
- }
- li.innerHTML=`${test}...`;
- let status='✅';
+
const outUrl=`./tests/${test}/outputs/${sModel}.js`;
- const srcP=fetch(outUrl).then(r=>r.text()).catch(()=>'');
+ // Check if file exists by trying to fetch head or text
+ const srcP=fetch(outUrl).then(r=>{
+ if(!r.ok) throw new Error('404');
+ return r.text();
+ }).catch(()=>null);
+
+ li.innerHTML=`${test}...`;
+
+ const src=await srcP;
+ if(src===null){
+ li.innerHTML=`— ${test}N/A`;
+ continue;
+ }
+ ran++;
+ let status='✅';
try{
const testP=(async()=>{
const tMod=await import(`./tests/${test}/test.js`);
@@ -127,20 +141,18 @@
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} ${test}${timeStr}s`;
+ const timeStr=fTime?`${parseFloat(fTime).toFixed(3)}s`:'N/A';
+ li.innerHTML=`${status} ${test}${timeStr}`;
}
- const ratio=tests.length?passed/tests.length:0;
+ const ratio=ran?passed/ran: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=`
Score
- ${passed}/${tests.length}
+ ${passed}/${ran}
${grade}
`;
list.appendChild(li);