Spaces:
Running
Running
Download app.js from THULab/CompressionBenchmark: direct link, hf CLI and curl.
- Browser
- Download file 82.6 kB
-
https://huggingface.co/spaces/THULab/CompressionBenchmark/resolve/main/app.js
- Command line
-
hf download hf://spaces/THULab/CompressionBenchmark/app.js
-
curl -L -o app.js https://huggingface.co/spaces/THULab/CompressionBenchmark/resolve/main/app.js
82.6 kB
| import {PROJECT200_SCOPE,PROJECT200_INPUT_STATUS,applyProject200Scope,filterProject200Catalog,project200CoverageForFamily} from './project200-scope.js?v=20261025-clean200-v1'; | |
| import {WEIGHT_TENTHS,parseWeights,addRankingMetrics} from './ranking.js?v=20261021-bos-reger-rank85-v1'; | |
| import {DEFAULT_PROFILE,profileLabel,defaultColumnVisible,metricAvailability,summarizeAvailability,visibleColumns,profileScopeText,aggregateTimedSubset,strictTimingMode} from './availability.js?v=20261023-clean150-v1-ui-scope2'; | |
| const UI_DATA_SHA256='160e49e5afcb8a27e0e48e311fe1838d70930782d659dc5c444b9b0f4faebf59'; | |
| const UI_DATA_GZIP_SHA256='c2f0f46fc5c715af4da8f43101cada390c32e10e04f9fdbfb5e8896723daab65'; | |
| const CPP_LATEST_VIEW_SHA256='f6ba04065b400361ba6e7da93b4e336d02cd03687448f1f337738d533505edb2'; | |
| const CPP_LATEST_VIEW_GZIP_SHA256='1a36afc4f34ef09d4e71f76a95c3ae4b42026a1cc31a4006d457143c582a4762'; | |
| const OPERATOR97_SHA256='370a01786db4d034d49117ee76c5f8999a9514192ee61ebca7151bed481739e0'; | |
| const OPERATOR97_GZIP_SHA256='0d41c7d4f9c63d0af50f63fc39c83a2e21e5fc40512101090a0c5f5d752d7f00'; | |
| const DATASET_CATALOG_SHA256='e25642fe1d87ab0bb595a391f4582c43ab94b9d6ae5ebd2be9903ccf261c1fd2'; | |
| const DATASET_CATALOG_GZIP_SHA256='b6d261c84e236efba34618975db37fb481f60e50e5682074fd103d784c1bb9f4'; | |
| const CLEAN200_ASSET_BASE='https://huggingface.co/datasets/THULab/TSCB_dataset/resolve/eb44d8917c982e9a6fa283bdee1ff894a406d8ff/benchmark-results/clean200_20261025_v4'; | |
| const clean200AssetUrl=(name)=>`${CLEAN200_ASSET_BASE}/${name}`; | |
| const $ = (id) => document.getElementById(id); | |
| const escape = (value) => String(value ?? '').replace(/[&<>"']/g, (c) => ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c])); | |
| const number = (v) => v != null && Number.isFinite(Number(v)) ? Number(v) : null; | |
| const mean = (values) => { const a = values.map(number).filter((n) => n !== null); return a.length ? a.reduce((s,n) => s+n,0)/a.length : null; }; | |
| function timingMode(input) { | |
| return strictTimingMode(input); | |
| } | |
| function aggregateTime(input,key) { | |
| const mode=timingMode(input); | |
| if(mode==='unavailable')return null; | |
| if(mode==='dataset_mean')return mean(input.map(r=>r[key])); | |
| return input.reduce((sum,r)=>sum+r[key]*r.timing_column_count,0)/input.reduce((sum,r)=>sum+r.timing_column_count,0); | |
| } | |
| const timingLabel=mode=>({column_mean:'Equal-column arithmetic mean',dataset_mean:'Equal-dataset arithmetic mean',dataset_aggregate:'Dataset aggregate',unavailable:'Unavailable'}[mode]??'Unavailable'); | |
| const fmt = (v, digits=3) => number(v) === null ? 'Unavailable' : Number(v).toLocaleString('en-US',{maximumFractionDigits:digits,minimumFractionDigits:digits}); | |
| const countFmt = (v) => Number(v).toLocaleString('en-US'); | |
| const runtimeName = (v) => profileLabel(v,snapshot?.benchmark?.runtime_labels?.[v] || ({cpp:'C++',java:'Java',python:'Python'}[v] || v)); | |
| const runtimeHost = (v) => v==='cpp'?'receipt-bound source environments':snapshot?.benchmark?.runtime_hosts?.[v] || 'source snapshot'; | |
| const THULAB_DATASET_PREFIX='https://huggingface.co/datasets/THULab/'; | |
| const requestedDataset=new URLSearchParams(location.search).get('dataset')?.trim()||''; | |
| let requestedDatasetApplied=false; | |
| const cols = [ | |
| {key:'average_rank',label:'Average Rank ↓',digits:2,visible:true,defaultVisible:true,overallOnly:true}, | |
| {key:'rank_coverage',label:'Rank coverage',digits:0,visible:true,defaultVisible:true,overallOnly:true}, | |
| {key:'composite_score',label:'Composite score ↓',digits:4,visible:true,defaultVisible:true,overallOnly:true}, | |
| {key:'compression_rate',label:'Average rate ↓',digits:4,visible:true,defaultVisible:true}, | |
| {key:'overall_rate',label:'Overall rate ↓',digits:4,visible:false,defaultVisible:false}, | |
| {key:'compression_time',label:'Compress ns/point ↓',digits:2,visible:true,defaultVisible:true}, | |
| {key:'decompression_time',label:'Decompress ns/point ↓',digits:2,visible:true,defaultVisible:true}, | |
| {key:'compression_time_timed_subset',label:'Compress ns/point · timed subset ↓',digits:2,visible:true,defaultVisible:true}, | |
| {key:'decompression_time_timed_subset',label:'Decompress ns/point · timed subset ↓',digits:2,visible:true,defaultVisible:true}, | |
| {key:'normalized_compression_time',label:'Normalized compress ↓',digits:4,visible:false,defaultVisible:false,overallOnly:true}, | |
| {key:'normalized_decompression_time',label:'Normalized decompress ↓',digits:4,visible:false,defaultVisible:false,overallOnly:true}, | |
| {key:'timing_column_count',label:'Measured columns',digits:0,visible:false,defaultVisible:false}, | |
| {key:'compressed_bytes',label:'Compressed bytes',digits:0,visible:false,defaultVisible:false}, | |
| {key:'original_bytes',label:'Original bytes',digits:0,visible:false,defaultVisible:false}, | |
| ]; | |
| let snapshot, records=[], methods=new Map(), datasets=new Map(), currentRows=[], activeTab='overall'; | |
| let cppLatestView=null; | |
| let referenceCatalog=null,referenceCatalogError=null,datasetCatalog=null,datasetCatalogError=null; | |
| let operatorEffect=null,operatorEffectError=null; | |
| let operator97=null,operator97Error=null; | |
| let sort={key:'compression_rate',direction:1}; | |
| let selectedMethod=null; | |
| const touchedColumns=new Set(); | |
| let legacyProfileRequested=''; | |
| const state = () => ({runtime:$('runtime').value,dataset:$('dataset').value,dtype:$('dtype').value,precision:$('precision').value,family:$('family').value,mode:$('row-mode').value,search:$('search').value.trim().toLowerCase(),complete:$('complete-only').checked}); | |
| function scopeKey() { const s=state(); return s.dtype==='overall'?'overall':s.dtype==='int'?'integer':s.precision==='fixed'?'fixed_float':s.precision==='non_fixed'?'nonfixed_float':'float'; } | |
| function syncInputContractControls() { | |
| const runtime=$('runtime'),dtype=$('dtype'),precision=$('precision'); | |
| const cleanCurrentCpp=runtime?.value==='cpp'; | |
| if(cleanCurrentCpp&&dtype?.value==='float')precision.value='all'; | |
| precision.disabled=dtype?.value!=='float'||cleanCurrentCpp; | |
| precision.setAttribute('aria-disabled',String(precision.disabled)); | |
| const label=precision.closest('label'); | |
| if(label)label.title=cleanCurrentCpp?'Current C++ clean-input results publish one combined numeric scope. Historical precision-specific C++ rows remain archived and do not enter the current ranking.':'This historical language view retains the precision categories and input contract of its published source snapshot.'; | |
| } | |
| function normalizeRecord(r) { | |
| const sourceRuntime=r.runtime ?? r.implementation_language ?? snapshot.benchmark?.implementation_language ?? 'cpp'; | |
| return { ...r,configuration:r.algorithm_variant??r.algorithm??r.method,method:r.algorithm_variant??r.algorithm??r.method,source_runtime:sourceRuntime,runtime:r.comparison_profile??sourceRuntime, | |
| family:r.family ?? r.method_family ?? r.method ?? methods.get(r.algorithm)?.family ?? r.algorithm, | |
| compression_rate:number(r.compression_rate ?? r.average_compression_rate),compression_time:number(r.compression_time_ns_per_point ?? r.compression_time),decompression_time:number(r.decompression_time_ns_per_point ?? r.decompression_time), | |
| original_bytes:number(r.original_size_bytes ?? r.original_bytes ?? r.originalSize),compressed_bytes:number(r.compressed_size_bytes ?? r.compressed_bytes ?? r.compressedSize), | |
| eligible_column_set_sha256:r.eligible_column_set_sha256??'legacy_snapshot_unbound',measurement_status:r.measurement_status??'legacy_published_measurement',timing_profile_status:r.timing_profile_status??'source_snapshot_timing',binary_sha256:r.binary_sha256??'unbound' }; | |
| } | |
| function filteredRecords(ignoreMethod=false) { | |
| const s=state(), scope=scopeKey(); | |
| let result=records.filter((r) => r.runtime===s.runtime && r.scope===scope && (s.dataset==='all'||r.dataset===s.dataset)); | |
| if(s.mode==='family') { | |
| const choices=new Map(),best=new Map(); | |
| for(const r of result){const key=`${r.dataset}\0${r.family}`;if(!choices.has(key))choices.set(key,[]);choices.get(key).push(r);} | |
| for(const [key,rows] of choices){if(new Set(rows.map(r=>r.eligible_column_set_sha256)).size!==1)continue;for(const r of rows){const prev=best.get(key);if(!prev||r.compression_rate<prev.compression_rate||(r.compression_rate===prev.compression_rate&&r.configuration.localeCompare(prev.configuration)<0))best.set(key,r);}} | |
| result=[...best.values()].map(r=>({...r,method:r.family})); | |
| } | |
| return ignoreMethod?result:result.filter(r=>(s.family==='all'||r.family===s.family)&&(!s.search||(s.mode==='family'?r.family:`${r.method} ${r.family}`).toLowerCase().includes(s.search))); | |
| } | |
| function coverageDatasetCount() { return new Set(filteredRecords(true).map(r=>r.dataset)).size; } | |
| function populateFamilyControl() { | |
| const control=$('family');if(!control)return; | |
| const selected=control.value,scope=scopeKey(),runtime=$('runtime').value; | |
| const families=[...new Set(records.filter(record=>record.runtime===runtime&&record.scope===scope).map(record=>record.family))].sort((a,b)=>a.localeCompare(b)); | |
| control.innerHTML='<option value="all">All method families</option>'+families.map(family=>`<option value="${escape(family)}">${escape(family)}</option>`).join(''); | |
| control.value=families.includes(selected)?selected:'all'; | |
| } | |
| function aggregate(input) { | |
| const groups=new Map(); | |
| const exact=state().mode==='configuration',familiesByConfiguration=new Map(); | |
| if(exact)for(const r of input){if(!familiesByConfiguration.has(r.method))familiesByConfiguration.set(r.method,new Set());familiesByConfiguration.get(r.method).add(r.family);} | |
| for(const r of input) { const key=exact?`${r.family}\0${r.method}`:r.method;if(!groups.has(key)) groups.set(key,[]); groups.get(key).push(r); } | |
| const totalDatasets=coverageDatasetCount(); | |
| const rows=[]; | |
| for(const [,source] of groups) { | |
| const configuration=source[0].method,method=exact&&familiesByConfiguration.get(configuration).size>1?`${source[0].family} · ${configuration}`:configuration; | |
| const hasBytes=source.every(r=>r.original_bytes!==null && r.original_bytes>0 && r.compressed_bytes!==null && r.compressed_bytes>0); | |
| const original=hasBytes?source.reduce((s,r)=>s+r.original_bytes,0):null, compressed=hasBytes?source.reduce((s,r)=>s+r.compressed_bytes,0):null; | |
| const timedSubset=aggregateTimedSubset(source); | |
| rows.push({method,family:source[0].family,runtime:source[0].runtime,compression_rate:mean(source.map(r=>r.compression_rate)),compression_time:aggregateTime(source,'compression_time'),decompression_time:aggregateTime(source,'decompression_time'),timing_column_count:source.reduce((sum,r)=>sum+(Number.isInteger(r.timing_column_count)?r.timing_column_count:0),0),timing_aggregation:timingMode(source),overall_rate:hasBytes?compressed/original:null,original_bytes:original,compressed_bytes:compressed,coverage:new Set(source.map(r=>r.dataset)).size,totalDatasets,source,...timedSubset}); | |
| } | |
| const s=state(); | |
| return addRankingMetrics(rows,parseWeights($('weights').value),{provisionalCurrentTiming:s.runtime==='cpp',fullPoolRankMethods:s.runtime==='cpp'&&s.mode==='family'?['BOS','REGER']:[]}).map(row=>row.normalization_reference_rows>=2?row:{...row,normalized_compression_time:null,normalized_decompression_time:null,composite_score:null}).filter(r=>(s.family==='all'||r.family===s.family)&&(!s.search||(s.mode==='family'?r.family:`${r.method} ${r.family}`).toLowerCase().includes(s.search))&&(!s.complete||r.coverage===totalDatasets)).sort((a,b)=>{ | |
| const av=number(a[sort.key]),bv=number(b[sort.key]); | |
| if(av===null&&bv===null)return a.method.localeCompare(b.method); | |
| if(av===null)return 1;if(bv===null)return -1; | |
| return sort.direction*(av-bv)||a.method.localeCompare(b.method); | |
| }); | |
| } | |
| function requestedColumns() { | |
| const profile=state().runtime; | |
| return cols.filter(column => touchedColumns.has(column.key)?column.visible:defaultColumnVisible(profile,column)); | |
| } | |
| function syncColumnOptions() { | |
| for(const input of $('column-options').querySelectorAll('input')){ | |
| const column=cols.find(item=>item.key===input.dataset.column); | |
| input.checked=touchedColumns.has(column.key)?column.visible:defaultColumnVisible(state().runtime,column); | |
| } | |
| } | |
| function metricCell(row,column) { | |
| if(column.key==='rank_coverage'&&number(row[column.key])!==null)return `${row.rank_coverage} / ${row.totalDatasets}`; | |
| if(number(row[column.key])!==null){ | |
| const subset=['compression_time_timed_subset','decompression_time_timed_subset'].includes(column.key); | |
| return `${fmt(row[column.key],column.digits)}${subset?` <span class="metric-coverage" title="Timed subset coverage">${row.timing_subset_coverage} / ${row.timing_subset_denominator}</span>`:''}`; | |
| } | |
| const unavailable=metricAvailability(row,column.key); | |
| return `<span class="unavailable-value" title="${escape(unavailable.detail)}">${escape(unavailable.short)}</span>`; | |
| } | |
| function renderTable() { | |
| const eligibleColumns=cols.filter(c=>!c.overallOnly||activeTab==='overall'); | |
| const visible=visibleColumns(eligibleColumns,currentRows,state().runtime,$('show-unavailable-columns').checked,touchedColumns); | |
| $('leaderboard').querySelector('thead').innerHTML=`<tr><th>Position</th><th>Method / configuration</th>${visible.map(c=>`<th aria-sort="${sort.key===c.key?(sort.direction===1?'ascending':'descending'):'none'}"><button data-sort="${c.key}" title="Sort ${escape(c.label)}">${escape(c.label)}${sort.key===c.key?(sort.direction===1?' ▴':' ▾'):''}</button></th>`).join('')}<th>Dataset coverage</th></tr>`; | |
| const minima=Object.fromEntries(visible.map(c=>[c.key,Math.min(...currentRows.map(r=>number(r[c.key])).filter(n=>n!==null))])); | |
| $('leaderboard').querySelector('tbody').innerHTML=currentRows.length?currentRows.map((r,i)=>`<tr><td class="rank numeric">${i+1}</td><td><button class="method-button" data-method="${escape(r.method)}">${escape(r.method)}</button>${activeTab==='overall'?'':`<span class="method-family">${escape(r.family)} · ${escape(runtimeName(r.runtime))}</span>`}</td>${visible.map(c=>`<td class="numeric ${!['compressed_bytes','original_bytes','rank_coverage','timing_column_count'].includes(c.key)&&number(r[c.key])!==null&&r[c.key]===minima[c.key]?'best':''}">${metricCell(r,c)}</td>`).join('')}<td><span class="coverage ${r.coverage===r.totalDatasets?'full':''}">${r.coverage} / ${r.totalDatasets}</span></td></tr>`).join(''):`<tr><td colspan="${visible.length+3}" class="empty-cell">No measurements match this selection. Try another runtime, data type, or dataset.</td></tr>`; | |
| for(const button of $('leaderboard').querySelectorAll('[data-sort]'))button.addEventListener('click',()=>{const key=button.dataset.sort;sort={key,direction:sort.key===key?-sort.direction:1};refresh();}); | |
| for(const button of $('leaderboard').querySelectorAll('[data-method]'))button.addEventListener('click',()=>showMethod(button.dataset.method,true)); | |
| $('row-count').textContent=`${currentRows.length} ${state().mode==='family'?'method families':'method configurations'} · sorted by ${cols.find(c=>c.key===sort.key)?.label??sort.key}`; | |
| $('download').disabled=!currentRows.length; | |
| const availability=summarizeAvailability(currentRows,requestedColumns()); | |
| const visibleKeys=new Set(visible.map(column=>column.key)),hiddenLabels=requestedColumns().filter(column=>!visibleKeys.has(column.key)).map(column=>column.label.replace(' ↓','')); | |
| const timedSubsetRows=currentRows.filter(row=>number(row.compression_time_timed_subset)!==null&&number(row.decompression_time_timed_subset)!==null).length; | |
| $('availability-summary').textContent=`Availability: ${availability.parts.join(' · ')} · ${timedSubsetRows}/${availability.total} timed-subset rows (each cell shows timed datasets / current rate datasets).${availability.reasons.length?` ${availability.reasons.join('; ')}.`:''}${hiddenLabels.length&&!$('show-unavailable-columns').checked?` Hidden columns without complete row coverage: ${hiddenLabels.join(', ')}. Use “Show unavailable metric columns” to inspect their explicit reasons.`:''}`; | |
| } | |
| function refresh() { | |
| if(!snapshot)return; | |
| syncInputContractControls(); | |
| const selectedDataset=state().dataset,selectedHasMeasurements=selectedDataset==='all'||records.some(r=>r.dataset===selectedDataset),inputContractNote=state().runtime==='cpp'?'Current C++ clean-input measurements remove NULL and IEEE NaN independently per numeric column. The all-float view includes every retained floating-point column; historical precision-specific C++ rows remain archived and do not enter this current ranking.':`${runtimeName(state().runtime)} results are historical published measurements under their original input contract; they are not relabeled as NULL/NaN-free clean-input results.`,columnCoverageNote=`Compress and Decompress times use equal-column arithmetic means when every selected dataset has column timings. If a method has aggregate-only timings in the selection, its dataset ns/point values are averaged with equal weight per dataset. Timing basis is shown in method details and CSV. Column coverage may differ by method. ${inputContractNote}`; | |
| if(!selectedHasMeasurements) { | |
| $('results-note').textContent=`No published measurements are available for this catalog dataset. It is excluded from rankings rather than treated as zero. ${columnCoverageNote}`; | |
| } else if(scopeKey()==='float'&&!records.some(r=>r.scope==='float')) { | |
| // The exporter must publish an explicit all-float scope; never combine | |
| // preaggregated fixed/non-fixed metrics and call it an all-float result. | |
| $('results-note').textContent=`All-float measurements are not available in this snapshot. Select a precision category. ${columnCoverageNote}`; | |
| } else $('results-note').textContent=`${state().mode==='family'?'Each family uses its lowest-rate measured configuration only when that dataset/family has one exact support set; ambiguous support sets are omitted. Configurations may differ across datasets; use Exact configuration for fixed parameters.':'Each row retains one exact configuration and its eligible support-set hash. Lower compression rates and lower ns/point are better.'} ${columnCoverageNote}`; | |
| currentRows=aggregate(filteredRecords(true)); | |
| syncColumnOptions(); | |
| const weights=parseWeights($('weights').value); | |
| const scoreAvailability=summarizeAvailability(currentRows,cols); | |
| const currentTimingRows=currentRows.filter(row=>row.composite_score_status==='provisional_current_admitted_timing'); | |
| const scoreStatus=!currentRows.length?'No candidate rows are visible; comparability is not inferred.':currentTimingRows.length===currentRows.length?`${currentTimingRows.length}/${currentRows.length} composite scores use every method's current accepted rate and comparable timing coverage.`:scoreAvailability.counts.composite_score===currentRows.length?'Composite scores use one complete exact dataset/support signature.':`Composite scores are unavailable for ${currentRows.length-scoreAvailability.counts.composite_score}/${currentRows.length} rows because a positively weighted metric is missing.`; | |
| $('score-note').textContent=`Score = ${weights[0].toFixed(1)} × average rate + ${weights[1].toFixed(1)} × normalized compress + ${weights[2].toFixed(1)} × normalized decompress. Lower is better. ${scoreStatus} Weights remain fixed and are not renormalized; a zero-weight metric is not required. C++ timing coverage remains available in CSV and method details. ${state().runtime==='cpp'&&state().mode==='family'?'BOS and REGER Average Rank uses all admitted published methods in the selected scope; other methods retain their existing matched-support ranks.':'Average Rank keeps the matched dataset/support rule.'} Missing, N/A and failed results receive no rank.`; | |
| const s=state(),scope=scopeKey(),measuredCount=coverageDatasetCount(),ds=s.dataset==='all'?`all ${measuredCount} measured datasets`:datasetDisplayName(s.dataset); | |
| $('dataset-count').textContent=countFmt(measuredCount);$('dataset-count-label').textContent='measured datasets'; | |
| $('method-count').textContent=countFmt(new Set(records.filter(record=>record.runtime===s.runtime&&record.scope===scope).map(record=>record.family)).size); | |
| const names={overall:'available numeric measurements',integer:'integer columns',float:'floating-point columns',fixed_float:'fixed-precision float columns',nonfixed_float:'non-fixed-precision float columns'}; | |
| $('selection-summary').textContent=`${runtimeName(s.runtime)} · ${names[scope]||scope} · ${ds} · ${currentRows.length} methods`; | |
| $('profile-scope-note').textContent=profileScopeText({profile:s.runtime,measuredDatasets:measuredCount,catalogDatasets:datasetEntries().length})+(legacyProfileRequested?` The requested historical profile “${legacyProfileRequested}” is now included in the combined C++ view; this is not an environment-specific view.`:''); | |
| $('view-title').textContent=activeTab==='dataset'?`${s.dataset==='all'?'Dataset':datasetDisplayName(s.dataset)} leaderboard`:activeTab==='tradeoffs'?'Storage and execution trade-offs':'Overall leaderboard'; | |
| const selectedEntry=s.dataset==='all'?null:datasets.get(s.dataset),selectedDatasetUrl=thulabDatasetUrl(selectedEntry),selectedBadge=$('selected-dataset-badge'); | |
| selectedBadge.hidden=!selectedDatasetUrl; | |
| if(selectedDatasetUrl){selectedBadge.href=selectedDatasetUrl;selectedBadge.setAttribute('aria-label',`Open ${datasetDisplayName(s.dataset)} in the THULab Hugging Face organization`);selectedBadge.title='Open this dataset in the THULab Hugging Face organization.';} | |
| renderTable(); | |
| if(activeTab==='tradeoffs')renderChart(); | |
| if(selectedMethod)showMethod(selectedMethod,false); | |
| } | |
| function setTab(tab) { | |
| activeTab=['overall','dataset','tradeoffs','methods','operators','about'].includes(tab)?tab:'overall'; | |
| for(const b of document.querySelectorAll('[data-tab]')){b.classList.toggle('active',b.dataset.tab===activeTab);if(b.dataset.tab===activeTab)b.setAttribute('aria-current','page');else b.removeAttribute('aria-current');} | |
| $('results-view').hidden=['methods','operators','about'].includes(activeTab);$('methods-view').hidden=activeTab!=='methods';$('operators-view').hidden=activeTab!=='operators';$('about-view').hidden=activeTab!=='about';$('chart-view').hidden=activeTab!=='tradeoffs';$('dataset-catalog-panel').hidden=activeTab!=='dataset'; | |
| $('score-controls').hidden=activeTab!=='overall'; | |
| for(const input of $('column-options').querySelectorAll('input'))input.parentElement.hidden=Boolean(cols.find(c=>c.key===input.dataset.column)?.overallOnly&&activeTab!=='overall'); | |
| if(activeTab!=='overall'&&cols.find(c=>c.key===sort.key)?.overallOnly)sort={key:'compression_rate',direction:1}; | |
| if(activeTab==='dataset'&&$('dataset').value==='all'){const first=[...datasets.keys()].find(k=>records.some(r=>r.dataset===k&&r.runtime===$('runtime').value));if(first)$('dataset').value=first;} | |
| if(activeTab==='overall')$('dataset').value='all'; | |
| if(activeTab==='dataset')renderDatasetCatalog(); | |
| updateUrlState(); | |
| refresh(); | |
| } | |
| function showMethod(method,focus=false) { | |
| const row=currentRows.find(r=>r.method===method), detail=$('method-detail'); | |
| if(!row){selectedMethod=null;detail.hidden=true;return;}selectedMethod=method; | |
| const meta=methods.get(method)??methods.get(row.source[0].configuration), pipeline=meta?.operator_pipeline; | |
| const source=row.source.slice().sort((a,b)=>a.dataset.localeCompare(b.dataset)); | |
| const supportDecisions=row.runtime==='cpp'?project200CoverageForFamily(cppLatestView.cpp.pair_ledger,row.family):[]; | |
| const countSupport=predicate=>supportDecisions.filter(predicate).length; | |
| const supportNote=supportDecisions.length?`C++ test scope: ${supportDecisions.length} dataset identities; ${countSupport(item=>item.status==='numeric'&&item.scopes.includes('overall'))} full numeric Overall, ${countSupport(item=>item.status==='partial_numeric')} partial numeric (exact supported subset), ${countSupport(item=>item.status==='numeric'&&!item.scopes.includes('overall'))} full numeric type-specific only, ${countSupport(item=>item.status==='not_applicable')} not applicable, ${countSupport(item=>item.status==='unsupported')} unsupported, ${countSupport(item=>item.status==='replacement_input_pending')} corrected-input retests pending. Type-specific results are available through the data-type filter; they are not missing experiments.`:''; | |
| const strictCompress=metricCell(row,cols.find(column=>column.key==='compression_time')),strictDecompress=metricCell(row,cols.find(column=>column.key==='decompression_time')),subsetCompress=metricCell(row,cols.find(column=>column.key==='compression_time_timed_subset')),subsetDecompress=metricCell(row,cols.find(column=>column.key==='decompression_time_timed_subset')); | |
| const detailTimingNote=row.rank_reference==='all-published-methods-in-selected-scope'?'Dataset-level Average Rank compares every admitted published method in the selected scope; source support identities are retained.':row.runtime==='cpp'?'The C++ composite uses the current accepted comparable timing set and shows its coverage. Dataset-level Average Rank still uses exact matched support.':'Composite scores keep the strict complete-support rule. Dataset-level Average Rank uses exact matched support.'; | |
| detail.innerHTML=`<div class="detail-head"><div><h2 id="detail-title">${escape(method)}</h2><p class="muted">${escape(row.family)} · ${escape(runtimeName(row.runtime))} · ${row.coverage} measured datasets</p></div><button id="close-detail" class="quiet-button">Close details</button></div><div class="detail-grid"><div><strong>${fmt(row.compression_rate,4)}</strong><span>average compression rate</span></div><div><strong>${strictCompress}</strong><span>strict Compress ns/point</span></div><div><strong>${strictDecompress}</strong><span>strict Decompress ns/point</span></div><div><strong>${subsetCompress}</strong><span>Compress ns/point · timed subset</span></div><div><strong>${subsetDecompress}</strong><span>Decompress ns/point · timed subset</span></div><div><strong>${row.coverage} / ${row.totalDatasets}</strong><span>dataset coverage</span></div></div>${pipeline?`<p class="source-code">Interpretive operator mapping: ${escape(typeof pipeline==='string'?pipeline:JSON.stringify(pipeline))}</p>`:''}${supportNote?`<p class="notice">${escape(supportNote)}</p>`:''}<p class="muted">Strict timing average: ${escape(timingLabel(row.timing_aggregation))}. ${escape(detailTimingNote)} Dataset metrics below retain the winning row's source family, profile, and host.</p><div class="detail-table"><table><thead><tr><th>Dataset</th><th>Configuration</th><th>Source family</th><th>Rate ↓</th><th>Compress ns/point ↓</th><th>Decompress ns/point ↓</th><th>Timing basis</th><th>Measurement evidence</th><th>Timing profile</th><th>Selected source profile / host</th><th>Runtime / binary</th><th>Support set</th><th>Original bytes</th><th>Compressed bytes</th><th>Dataset score ↓</th><th>Dataset Rank ↓</th><th>Rank candidates</th></tr></thead><tbody>${source.map(r=>`<tr><td>${escape(r.dataset)}</td><td>${escape(r.configuration)}</td><td>${escape(r.source_family??r.family)}</td><td class="numeric">${fmt(r.compression_rate,4)}</td><td class="numeric">${metricCell(r,cols.find(column=>column.key==='compression_time'))}</td><td class="numeric">${metricCell(r,cols.find(column=>column.key==='decompression_time'))}</td><td>${escape(timingLabel(r.timing_aggregation))}</td><td>${escape(r.measurement_status)}</td><td>${escape(r.timing_profile_status)}</td><td class="source-code">${escape(r.source_comparison_profile??r.runtime)} / ${escape(r.source_execution_host??'source snapshot')}</td><td class="source-code">${escape(r.source_runtime)} / ${escape(String(r.binary_sha256).slice(0,16))}</td><td class="source-code">${escape(String(r.eligible_column_set_sha256).slice(0,16))}</td><td class="numeric">${fmt(r.original_bytes,0)}</td><td class="numeric">${fmt(r.compressed_bytes,0)}</td><td class="numeric">${metricCell(r,{key:'dataset_score',digits:4})}</td><td class="numeric">${metricCell(r,{key:'dataset_rank',digits:2})}</td><td class="numeric">${fmt(r.dataset_candidate_count,0)}</td></tr>`).join('')}</tbody></table></div>`; | |
| detail.hidden=false;$('close-detail').addEventListener('click',()=>{detail.hidden=true;selectedMethod=null;}); | |
| if(focus){detail.scrollIntoView({block:'nearest',behavior:'auto'});detail.focus({preventScroll:true});} | |
| } | |
| function renderChart() { | |
| const metric=$('chart-metric').value; | |
| const compressionMetric=metric.startsWith('compression'),subsetMetric=metric.includes('timed_subset'); | |
| const valid=currentRows.filter(r=>r.compression_rate>0&&r[metric]>0); | |
| if(!valid.length){$('chart').innerHTML='<p class="chart-empty muted">No positive measurements to plot for this selection.</p>';return;} | |
| const width=1100,height=410,pad={left:85,right:35,top:30,bottom:65}; | |
| const maxRate=Math.max(...valid.map(r=>r.compression_rate))*1.08; | |
| const logs=valid.map(r=>Math.log10(r[metric]));let minLog=Math.floor(Math.min(...logs)),maxLog=Math.ceil(Math.max(...logs));if(maxLog===minLog)maxLog=minLog+1; | |
| const x=r=>pad.left+r/maxRate*(width-pad.left-pad.right),y=n=>height-pad.bottom-(Math.log10(n)-minLog)/(maxLog-minLog)*(height-pad.top-pad.bottom); | |
| let graph=''; | |
| for(let i=0;i<=5;i++){const rate=maxRate*i/5,px=x(rate);graph+=`<line class="gridline" x1="${px}" y1="${pad.top}" x2="${px}" y2="${height-pad.bottom}"/><text class="axis-label" x="${px}" y="${height-pad.bottom+25}" text-anchor="middle">${fmt(rate,2)}</text>`;} | |
| for(let i=minLog;i<=maxLog;i++){const n=10**i,py=y(n);graph+=`<line class="gridline" x1="${pad.left}" y1="${py}" x2="${width-pad.right}" y2="${py}"/><text class="axis-label" x="${pad.left-12}" y="${py+4}" text-anchor="end">${n.toLocaleString('en-US',{maximumFractionDigits:3})}</text>`;} | |
| for(const r of valid)graph+=`<circle class="point" tabindex="0" role="button" aria-label="${escape(r.method)}: compression rate ${fmt(r.compression_rate,4)}, ${compressionMetric?'compression':'decompression'} ${fmt(r[metric],2)} ns per point${subsetMetric?`, timed subset ${r.timing_subset_coverage} of ${r.timing_subset_denominator} datasets`:''}" data-method="${escape(r.method)}" cx="${x(r.compression_rate)}" cy="${y(r[metric])}" r="6"><title>${escape(r.method)} | rate ${fmt(r.compression_rate,4)} | ${fmt(r[metric],2)} ns/point | ${subsetMetric?`timed subset ${r.timing_subset_coverage}/${r.timing_subset_denominator}`:`coverage ${r.coverage}/${r.totalDatasets}`}</title></circle>`; | |
| graph+=`<text class="axis-label" x="${width/2}" y="${height-13}" text-anchor="middle">Average compression rate (compressed / original) ↓</text><text class="axis-label" transform="translate(20 ${height/2}) rotate(-90)" text-anchor="middle">${compressionMetric?'Compress':'Decompress'} ns/point${subsetMetric?' · timed subset':''} (log scale) ↓</text>`; | |
| $('chart').innerHTML=`<svg viewBox="0 0 ${width} ${height}" role="img" aria-label="Measured compression rates versus ${compressionMetric?'compression':'decompression'} cost${subsetMetric?' for a timing-admitted subset':''}">${graph}</svg>`; | |
| for(const p of $('chart').querySelectorAll('[data-method]')){p.addEventListener('click',()=>showMethod(p.dataset.method,true));p.addEventListener('keydown',e=>{if(e.key==='Enter'||e.key===' '){e.preventDefault();showMethod(p.dataset.method,true);}});} | |
| } | |
| function csv() { | |
| const quote=v=>{let text=String(v??'');if(typeof v==='string'&&/^[=+@-]/.test(text))text="'"+text;return `"${text.replace(/"/g,'""')}"`;}; | |
| const weights=parseWeights($('weights').value); | |
| const columns=['position','method','comparison_profile','execution_host','scope','row_mode','selected_dataset','sort_metric','sort_direction','average_compression_rate','overall_compression_rate','compress_ns_per_point','decompress_ns_per_point','weight_a','weight_b','weight_c','normalized_compress','normalized_decompress','composite_score','composite_score_status','composite_rate_dataset_coverage','composite_timing_dataset_coverage','composite_timing_dataset_denominator','composite_metric_basis','average_rank','rank_dataset_coverage','normalization_reference_rows','compress_min','compress_max','decompress_min','decompress_max','normalization','rank_definition','dataset_coverage','datasets_in_scope','selected_configuration_by_dataset','source_profile_by_dataset','binary_sha256_by_dataset','eligible_column_set_sha256_by_dataset','measurement_status_by_dataset','timing_profile_status_by_dataset','timing_column_count','timing_aggregation','timed_subset_compress_ns_per_point','timed_subset_decompress_ns_per_point','timed_subset_dataset_coverage','timed_subset_dataset_denominator','timed_subset_status','timed_subset_source_profiles','timed_subset_source_hosts','selected_source_family_by_dataset','selected_source_comparison_profile_by_dataset','selected_source_host_by_dataset','strict_timing_reason','composite_reason','final_dataset_scope','input_version_gate','pending_replacement_datasets']; | |
| const body=currentRows.map((r,i)=>[i+1,r.method,r.runtime,runtimeHost(r.runtime),scopeKey(),state().mode,state().dataset,sort.key,sort.direction===1?'ascending':'descending',r.compression_rate,r.overall_rate,r.compression_time,r.decompression_time,...weights.map(w=>w.toFixed(1)),r.normalized_compression_time,r.normalized_decompression_time,r.composite_score,r.composite_score_status,r.composite_rate_coverage,r.composite_timing_coverage,r.composite_timing_denominator,r.composite_metric_basis,r.average_rank,r.rank_coverage,r.normalization_reference_rows,r.encode_min,r.encode_max,r.decode_min,r.decode_max,'min-max over all eligible rows in selected language/scope/row-mode before search and visibility filters; C++ scores use current accepted comparable timing inputs',(r.rank_reference==='all-published-methods-in-selected-scope'?'mean per-dataset composite-score fractional rank across all admitted published methods in selected scope; per-dataset min-max times':'mean per-dataset composite-score fractional rank; per-dataset min-max times'),r.coverage,r.totalDatasets,JSON.stringify(Object.fromEntries(r.source.map(s=>[s.dataset,s.configuration]))),JSON.stringify(Object.fromEntries(r.source.map(s=>[s.dataset,s.source_runtime]))),JSON.stringify(Object.fromEntries(r.source.map(s=>[s.dataset,s.binary_sha256]))),JSON.stringify(Object.fromEntries(r.source.map(s=>[s.dataset,s.eligible_column_set_sha256]))),JSON.stringify(Object.fromEntries(r.source.map(s=>[s.dataset,s.measurement_status]))),JSON.stringify(Object.fromEntries(r.source.map(s=>[s.dataset,s.timing_profile_status]))),r.timing_column_count,r.timing_aggregation,r.compression_time_timed_subset,r.decompression_time_timed_subset,r.timing_subset_coverage,r.timing_subset_denominator,r.timing_subset_status,JSON.stringify(r.timing_subset_source_profiles),JSON.stringify(r.timing_subset_hosts),JSON.stringify(Object.fromEntries(r.source.map(s=>[s.dataset,s.source_family??s.family]))),JSON.stringify(Object.fromEntries(r.source.map(s=>[s.dataset,s.source_comparison_profile??s.runtime]))),JSON.stringify(Object.fromEntries(r.source.map(s=>[s.dataset,s.source_execution_host??'source snapshot']))),metricAvailability(r,'compression_time').code,metricAvailability(r,'composite_score').code,PROJECT200_INPUT_STATUS.scope_id,'not_quarantined_by_current_input_audit',JSON.stringify(PROJECT200_INPUT_STATUS.pending_datasets.map(item=>item.dataset_id))].map(quote).join(',')); | |
| const url=URL.createObjectURL(new Blob(['\ufeff'+[columns.join(','),...body].join('\r\n')],{type:'text/csv;charset=utf-8'}));const a=document.createElement('a');a.href=url;a.download=`THULab-compression-${state().runtime}-${scopeKey()}-${state().dataset}.csv`;a.click();setTimeout(()=>URL.revokeObjectURL(url),1000); | |
| } | |
| function safeHttpUrl(value) { | |
| try { const url=new URL(String(value));return ['http:','https:'].includes(url.protocol)?url.href:null; } catch { return null; } | |
| } | |
| function thulabDatasetUrl(entry) { | |
| const url=safeHttpUrl(entry?.dataset_url); | |
| return url?.startsWith(THULAB_DATASET_PREFIX)?url:null; | |
| } | |
| function thulabDatasetBadge(entry,key=datasetKey(entry)) { | |
| const url=thulabDatasetUrl(entry);if(!url)return ''; | |
| return `<a class="thulab-dataset-badge" href="${escape(url)}" target="_blank" rel="noopener noreferrer" aria-label="Open ${escape(key)} in the THULab Hugging Face organization" title="Open this dataset in the THULab Hugging Face organization."><span aria-hidden="true">🏆</span> THULab hosted ↗</a>`; | |
| } | |
| function publicNote(value) { | |
| const note=typeof value==='string'?value.trim():''; | |
| return /(?:\/Users\/|[A-Za-z]:\\|file:\/\/|codex:\/\/threads\/|\.pptx\b)/i.test(note)?'':note; | |
| } | |
| function publicText(value,fallback='') { const text=publicNote(value);return text||fallback; } | |
| function referenceMap() { | |
| return new Map((referenceCatalog?.references||[]).map(reference=>[String(reference.id),reference])); | |
| } | |
| function resolvedReferences(ids) { | |
| const byId=referenceMap(); | |
| return [...new Set(Array.isArray(ids)?ids.map(String):[])].map(id=>byId.get(id)).filter(Boolean); | |
| } | |
| function referenceSearchText(ids) { | |
| return resolvedReferences(ids).map(reference=>`${reference.id??''} ${reference.citation??''} ${reference.kind??''}`).join(' '); | |
| } | |
| function renderReferences(ids) { | |
| const references=resolvedReferences(ids); | |
| if(!references.length)return '<p class="reference-empty">No external reference is listed for this entry.</p>'; | |
| return `<div class="documentation-references"><strong>References</strong><ul>${references.map(reference=>{const url=safeHttpUrl(reference.url),citation=escape(reference.citation||reference.id||'Reference');const meta=[reference.id,reference.source_slide?`Presentation Notes · slide ${reference.source_slide}`:'Additional official source'].filter(Boolean).map(escape).join(' · ');return `<li>${url?`<a href="${escape(url)}" target="_blank" rel="noopener noreferrer">${citation}</a>`:`<span>${citation}</span>`}${meta?`<small>${meta}</small>`:''}</li>`;}).join('')}</ul></div>`; | |
| } | |
| function familyConfigurations() { | |
| const grouped=new Map(); | |
| for(const record of records){if(!grouped.has(record.family))grouped.set(record.family,new Set());grouped.get(record.family).add(record.configuration);} | |
| return new Map([...grouped].map(([family,names])=>[family,[...names].sort((a,b)=>a.localeCompare(b))])); | |
| } | |
| function catalogMethod(family) { | |
| const entries=referenceCatalog?.methods||[]; | |
| return entries.find(entry=>entry.family===family)||entries.find(entry=>String(entry.family).toLowerCase()===family.toLowerCase())||null; | |
| } | |
| function renderMethodDocumentation() { | |
| const container=$('method-catalog'),status=$('method-doc-status'); | |
| if(!container||!status)return; | |
| if(referenceCatalogError){status.textContent='Method documentation could not be loaded.';container.innerHTML=`<p class="documentation-error">${escape(referenceCatalogError.message)}</p>`;return;} | |
| if(!referenceCatalog){status.textContent='Loading method documentation…';container.innerHTML='';return;} | |
| const configurations=familyConfigurations(),query=$('method-doc-search').value.trim().toLowerCase(); | |
| const families=[...configurations.keys()].sort((a,b)=>a.localeCompare(b)); | |
| const rows=families.map(family=>{const entry=catalogMethod(family)||{},names=configurations.get(family),note=publicNote(entry.notes),search=[family,entry.display_name,entry.description,note,...names,referenceSearchText(entry.reference_ids)].join(' ').toLowerCase();return {family,entry,names,note,search};}).filter(row=>!query||row.search.includes(query)); | |
| const described=families.filter(family=>catalogMethod(family)?.description).length; | |
| status.textContent=`${rows.length} of ${families.length} measured method families shown · ${described} descriptions available`; | |
| container.innerHTML=rows.length?rows.map(({family,entry,names,note})=>{const display=entry.display_name||family;return `<article class="documentation-card"><div class="documentation-card-head"><div><h3>${escape(display)}</h3>${display!==family?`<span class="documentation-code">${escape(family)}</span>`:''}</div><span class="documentation-count">${names.length} configuration${names.length===1?'':'s'}</span></div><p class="documentation-description">${escape(entry.description||'A reference description is not available for this measured family.')}</p>${note?`<p class="documentation-note">${escape(note)}</p>`:''}${renderReferences(entry.reference_ids)}<details class="configuration-details"><summary>Published configurations (${names.length})</summary><ul>${names.map(name=>`<li>${escape(name)}</li>`).join('')}</ul></details></article>`;}).join(''):'<p class="documentation-empty">No method documentation matches this search.</p>'; | |
| } | |
| /* OPERATOR97_CSV_BEGIN */ | |
| const OPERATOR97_CSV_FIELDS=['dataset_id','implementation_id','implementation_name','implementation_family','status','ranking_eligible','column_count','supported_columns','not_executable_columns','valid_count','h0_delta_bits_per_valid_value','markov3_delta_bits_per_valid_value','bundle_h0_delta_bits_per_byte','bundle_h3_delta_bits_per_byte','ablation_zstd3_delta_bits_per_valid_value','ablation_present_over_omitted_compressed_bytes','operator_present_zstd3_bytes','operator_omitted_zstd3_bytes','bitexact']; | |
| function operator97CsvCell(value) { if(value===null||value===undefined)return '';const text=String(value);return /[",\n\r]/.test(text)?`"${text.replaceAll('"','""')}"`:text; } | |
| function operator97CsvText(value=operator97) { | |
| const metadata=new Map(value.implementations.map(row=>[row.implementation_id,row])); | |
| const rows=value.dataset_results.map(row=>({...row,implementation_name:metadata.get(row.implementation_id)?.name||row.implementation_id,implementation_family:metadata.get(row.implementation_id)?.family||''})); | |
| return [OPERATOR97_CSV_FIELDS.join(','),...rows.map(row=>OPERATOR97_CSV_FIELDS.map(field=>operator97CsvCell(row[field])).join(','))].join('\n')+'\n'; | |
| } | |
| /* OPERATOR97_CSV_END */ | |
| function downloadOperator97Csv() { | |
| if(!operator97)return; | |
| const blob=new Blob([operator97CsvText(operator97)],{type:'text/csv;charset=utf-8'}),url=URL.createObjectURL(blob),link=document.createElement('a'); | |
| link.href=url;link.download='operator97-project200-dataset-results.csv';document.body.appendChild(link);link.click();link.remove();setTimeout(()=>URL.revokeObjectURL(url),0); | |
| } | |
| function operator97Metric(value,digits=3) { return number(value)===null?'Unavailable':fmt(value,digits); } | |
| function renderOperator97() { | |
| const status=$('operator97-status'),body=$('operator97-table')?.querySelector('tbody'),datasetControl=$('operator97-dataset');if(!status||!body||!datasetControl)return; | |
| if(operator97Error){status.textContent='Operator97 results could not be loaded.';body.innerHTML=`<tr><td colspan="8" class="empty-cell">${escape(operator97Error.message)}</td></tr>`;return;} | |
| if(!operator97){status.textContent='Loading Operator97 results…';return;} | |
| if(datasetControl.options.length<2){datasetControl.innerHTML='<option value="all">All 200 datasets · dataset-equal means</option>'+operator97.datasets.map(value=>`<option value="${escape(value)}">${escape(value)}</option>`).join('');} | |
| const selected=datasetControl.value||'all',query=($('operator97-search')?.value||'').trim().toLowerCase(),meta=new Map(operator97.implementations.map(row=>[row.implementation_id,row])); | |
| let rows=selected==='all'?operator97.implementations:operator97.dataset_results.filter(row=>row.dataset_id===selected).map(row=>({...meta.get(row.implementation_id),...row,eligible_dataset_count:row.ranking_eligible?1:0,dataset_count:1})); | |
| rows=rows.filter(row=>!query||`${row.implementation_id} ${row.name} ${row.family}`.toLowerCase().includes(query)); | |
| const eligible=rows.filter(row=>selected==='all'?row.ranking_eligible_full_200:row.ranking_eligible).length,coverage=operator97.coverage; | |
| status.textContent=selected==='all'?`${rows.length} implementations shown · ${eligible} have complete 200-dataset support · ${countFmt(operator97.dataset_results.filter(row=>row.ranking_eligible).length)} rank-eligible dataset results · ${countFmt(operator97.dataset_results.filter(row=>!row.ranking_eligible).length)} domain-limited results excluded from metrics and ranking`:`${escape(selected)} · ${rows.length} implementations shown · ${eligible} executable complete results; domain-limited rows remain visible but have no scientific score`; | |
| body.innerHTML=rows.map(row=>{const eligibleRow=selected==='all'?row.ranking_eligible_full_200:row.ranking_eligible,statusText=selected==='all'?(eligibleRow?'Complete 200 / 200':`${row.eligible_dataset_count} / 200 · support-limited`):(eligibleRow?'Executable · bitexact':row.status.replaceAll('_',' '));return `<tr class="${eligibleRow?'':'operator97-ineligible'}"><td><strong>${escape(row.implementation_id)}</strong><small>${escape(row.name)}</small></td><td class="numeric">${operator97Metric(row.h0_delta_bits_per_valid_value)}</td><td class="numeric">${operator97Metric(row.markov3_delta_bits_per_valid_value)}</td><td class="numeric">${operator97Metric(row.ablation_zstd3_delta_bits_per_valid_value)}</td><td class="numeric">${operator97Metric(row.ablation_present_over_omitted_compressed_bytes)}${number(row.ablation_present_over_omitted_compressed_bytes)!==null?'×':''}</td><td class="numeric">${selected==='all'?`${row.eligible_dataset_count} / 200`:`${row.supported_columns??0} / ${row.column_count??0}`}</td><td>${escape(statusText)}</td><td><code>${escape((row.support_cohort_sha256||'').slice(0,12)||'—')}</code></td></tr>`;}).join('')||'<tr><td colspan="8" class="empty-cell">No implementation matches this filter.</td></tr>'; | |
| } | |
| async function loadOperator97() { | |
| try { | |
| const response=await fetch(clean200AssetUrl('operator97-project200-summary.json.gz'),{cache:'no-cache'});if(!response.ok)throw new Error(`Operator97 request returned ${response.status}.`); | |
| const compressed=await response.arrayBuffer();if(await sha256Hex(compressed)!==OPERATOR97_GZIP_SHA256)throw new Error('Operator97 compressed summary SHA differs.');const bytes=await gunzipBuffer(compressed,'The Operator97 summary');if(await sha256Hex(bytes)!==OPERATOR97_SHA256)throw new Error('Operator97 summary SHA differs.');const value=JSON.parse(new TextDecoder().decode(bytes));if(value?.schema!=='compressionbenchmark-operator97-project200-summary-v1'||value?.status!=='accepted_clean200_complete'||value?.coverage?.dataset_count!==200||value?.coverage?.implementation_count!==97||value?.coverage?.dataset_implementation_key_count!==19400||value?.coverage?.column_implementation_key_count!==361131||!Array.isArray(value.implementations)||value.implementations.length!==97||!Array.isArray(value.dataset_results)||value.dataset_results.length!==19400)throw new Error('Operator97 summary has an invalid schema, scope, or source binding.');operator97=value; | |
| } catch(error) { operator97Error=error instanceof Error?error:new Error('Operator97 results are unavailable.'); } | |
| renderOperator97(); | |
| } | |
| function renderOperatorEffect() { | |
| const status=$('operator-effect-status'),body=$('operator-effect-table')?.querySelector('tbody');if(!status||!body)return; | |
| if(operatorEffectError){status.textContent='Operator byte-effect results could not be loaded.';body.innerHTML=`<tr><td colspan="7" class="empty-cell">${escape(operatorEffectError.message)}</td></tr>`;return;} | |
| if(!operatorEffect){status.textContent='Loading byte effects…';return;} | |
| const rows=operatorEffect.rows||[],coverage=operatorEffect.coverage||{}; | |
| status.textContent=`${countFmt(coverage.scope_identity_count)} dataset scope · ${countFmt(coverage.column_complete_identity_count)} identities with complete canonical key coverage · ${countFmt(coverage.observed_recipe_key_count)} / ${countFmt(coverage.expected_recipe_key_count)} recipe keys · ${countFmt(coverage.missing_recipe_key_count)} missing · timing unavailable`; | |
| body.innerHTML=rows.map(row=>`<tr><td>${escape(row.display_label)}</td><td class="numeric">${fmt(row.mean_rate_multiple_after_over_before,3)}×</td><td class="numeric">${fmt(100*(row.mean_rate_multiple_after_over_before-1),1)}%</td><td class="numeric">${fmt(row.mean_baseline_to_original_ratio,3)}</td><td class="numeric">${fmt(row.mean_omission_to_original_ratio,3)}</td><td class="numeric">${countFmt(row.admitted_dataset_count)}</td><td class="numeric">${countFmt(row.admitted_value_column_count)}</td></tr>`).join(''); | |
| } | |
| async function loadOperatorEffect() { | |
| try { | |
| const response=await fetch('./operator-byte-effect-current135-summary.json?v=20261016-current135-complete-v2',{cache:'no-cache'});if(!response.ok)throw new Error(`Operator byte-effect request returned ${response.status}.`); | |
| const value=await response.json();if(value?.schema!=='compressionbenchmark-operator-byte-effect-current135-complete-key-coverage-v2'||value?.timing_fields_all_null!==true||value?.canonical_key_coverage_complete!==true||value?.current_input_qualified!==false||value?.coverage?.observed_recipe_key_count!==35190||value?.coverage?.missing_recipe_key_count!==0||!Array.isArray(value.rows))throw new Error('Operator byte-effect summary has an invalid schema or boundary.');operatorEffect=value; | |
| } catch(error) { operatorEffectError=error instanceof Error?error:new Error('Operator byte-effect summary is unavailable.'); } | |
| renderOperatorEffect(); | |
| } | |
| function renderOperatorDocumentation() { | |
| const container=$('operator-catalog'),status=$('operator-doc-status'); | |
| if(!container||!status)return; | |
| if(referenceCatalogError){status.textContent='Operator documentation could not be loaded.';container.innerHTML=`<p class="documentation-error">${escape(referenceCatalogError.message)}</p>`;return;} | |
| if(!referenceCatalog){status.textContent='Loading operator documentation…';container.innerHTML='';return;} | |
| const query=$('operator-doc-search').value.trim().toLowerCase(),all=referenceCatalog.operators||[]; | |
| const rows=all.map(operator=>{const implementations=Array.isArray(operator.implementations)?operator.implementations:[];const familySearch=[operator.id,operator.name,operator.name_en,operator.name_zh,operator.group,operator.description,referenceSearchText(operator.reference_ids)].join(' ').toLowerCase();const matchingImplementations=query&&!familySearch.includes(query)?implementations.filter(entry=>operatorImplementationSearch(entry).includes(query)):implementations;return {operator,implementations:matchingImplementations,familyMatch:!query||familySearch.includes(query)};}).filter(row=>row.familyMatch||row.implementations.length); | |
| const groups=new Map(); | |
| for(const row of rows){const group=row.operator.group||'Other';if(!groups.has(group))groups.set(group,[]);groups.get(group).push(row);} | |
| const shownEntries=new Set(rows.flatMap(row=>row.implementations.map(entry=>entry.id||`${row.operator.id}:${entry.name||entry.name_en||''}`))).size,totalEntries=new Set(all.flatMap(operator=>(operator.implementations||[]).map(entry=>entry.id||`${operator.id}:${entry.name||entry.name_en||''}`))).size; | |
| status.textContent=`${rows.length} of ${all.length} operator families shown · ${shownEntries} of ${totalEntries} directory entries shown`; | |
| renderOperatorSummary(); | |
| container.innerHTML=rows.length?[...groups].map(([group,groupRows])=>`<section class="operator-group"><h3>${escape(publicText(group,'Other'))}</h3><div class="documentation-grid">${groupRows.map(({operator,implementations})=>renderOperatorCard(operator,implementations)).join('')}</div></section>`).join(''):'<p class="documentation-empty">No operator family or implementation entry matches this search.</p>'; | |
| } | |
| function operatorImplementationSearch(entry) { | |
| return [entry.id,entry.name,entry.name_en,entry.name_zh,entry.layer,entry.description,entry.inputs,entry.outputs,entry.example,entry.status,referenceSearchText(entry.reference_ids)].join(' ').toLowerCase(); | |
| } | |
| function renderOperatorSummary() { | |
| const target=$('operator-summary');if(!target||!referenceCatalog)return; | |
| const summary=referenceCatalog.operator_summary||{},families=number(summary.family_count??summary.operator_family_count)??(referenceCatalog.operators||[]).length; | |
| const entries=number(summary.entry_count??summary.directory_entry_count??summary.implementation_count)??(referenceCatalog.operators||[]).reduce((sum,item)=>sum+(item.implementations?.length||0),0); | |
| const parts=[['Families',families],['Directory entries',entries],['Mechanisms',summary.mechanism_count],['Configurations',summary.configuration_count],['Compositions',summary.composition_count],['Adapters',summary.adapter_count]]; | |
| target.innerHTML=parts.filter(([,value])=>number(value)!==null).map(([label,value])=>`<div><strong>${countFmt(value)}</strong><span>${escape(label)}</span></div>`).join(''); | |
| } | |
| function renderOperatorCard(operator,implementations) { | |
| const allEntries=Array.isArray(operator.implementations)?operator.implementations:[],name=publicText(operator.name_en??operator.name,operator.id||'Operator family'),nativeName=publicText(operator.name_zh),description=publicText(operator.description,'Description not available.'); | |
| return `<article class="documentation-card operator-card"><div class="documentation-card-head"><div><h4>${escape(name)}</h4>${nativeName&&nativeName!==name?`<span class="documentation-native-name">${escape(nativeName)}</span>`:''}${operator.id&&operator.id!==name?`<span class="documentation-code">${escape(publicText(operator.id))}</span>`:''}</div><span class="documentation-count">${implementations.length}${implementations.length!==allEntries.length?` / ${allEntries.length}`:''} entries</span></div><p class="documentation-description">${escape(description)}</p>${renderReferences(operator.reference_ids)}${implementations.length?`<details class="implementation-details"><summary>Implementation directory (${implementations.length}${implementations.length!==allEntries.length?` matching of ${allEntries.length}`:''})</summary><div class="implementation-list">${implementations.map(renderOperatorImplementation).join('')}</div></details>`:'<p class="reference-empty">No implementation entry matches this search.</p>'}</article>`; | |
| } | |
| function renderOperatorImplementation(entry) { | |
| const name=publicText(entry.name_en??entry.name,entry.id||'Implementation entry'),nativeName=publicText(entry.name_zh),layer=publicText(entry.layer,'entry'),fields=[['Principle',entry.description],['Input',entry.inputs],['Output',entry.outputs],['Example',entry.example],['Status',entry.status]].filter(([,value])=>publicText(value)); | |
| return `<article class="implementation-entry"><div class="implementation-head"><div><strong>${escape(name)}</strong>${nativeName&&nativeName!==name?`<span class="documentation-native-name">${escape(nativeName)}</span>`:''}${entry.id?`<span class="documentation-code">${escape(publicText(entry.id))}</span>`:''}</div><span class="implementation-layer">${escape(layer)}</span></div>${fields.length?`<dl>${fields.map(([label,value])=>`<div><dt>${escape(label)}</dt><dd>${escape(publicText(value))}</dd></div>`).join('')}</dl>`:''}${entry.reference_ids?.length?renderReferences(entry.reference_ids):''}</article>`; | |
| } | |
| function renderDocumentationViews() { renderMethodDocumentation();renderOperatorDocumentation();renderOperator97();renderOperatorEffect(); } | |
| async function loadReferenceCatalog() { | |
| try { | |
| const response=await fetch('./reference-catalog.json?v=20261021-target-only-preserved-v1',{cache:'no-cache'}); | |
| if(!response.ok)throw new Error(`Reference catalog request returned ${response.status}.`); | |
| const catalog=await response.json(); | |
| if(!catalog||!Array.isArray(catalog.methods)||!Array.isArray(catalog.operators)||!Array.isArray(catalog.references))throw new Error('Reference catalog has an invalid schema.'); | |
| referenceCatalog=catalog; | |
| } catch(error) { referenceCatalogError=error instanceof Error?error:new Error('Reference catalog is unavailable.'); } | |
| if(snapshot)renderDocumentationViews(); | |
| } | |
| function datasetKey(entry) { return String(entry?.key??entry?.dataset??''); } | |
| function datasetDisplayName(key) { const entry=datasets.get(key);return entry?.label&&entry.label!==key?`${entry.label} (${key})`:key; } | |
| function datasetEntries() { | |
| const source=Array.isArray(datasetCatalog?.datasets)&&datasetCatalog.datasets.length?datasetCatalog.datasets:[...(snapshot?.datasets||[])]; | |
| const unique=new Map();for(const entry of source){const key=datasetKey(entry);if(key&&PROJECT200_SCOPE.datasets.includes(key))unique.set(key,entry);}return [...unique.values()]; | |
| } | |
| function datasetCategory(entry) { return String(entry.category_label??entry.category??'Other'); } | |
| function datasetSearchText(entry) { return [datasetKey(entry),entry.label,entry.category,entry.category_label,entry.source,entry.dataset_url,thulabDatasetUrl(entry)?'THULab Hugging Face hosted':''].join(' ').toLowerCase(); } | |
| function humanBytes(value) { const amount=number(value);if(amount===null)return '';const units=['B','KB','MB','GB','TB'];let scaled=amount,index=0;while(scaled>=1000&&index<units.length-1){scaled/=1000;index++;}return `${scaled.toLocaleString('en-US',{maximumFractionDigits:index?1:0})} ${units[index]}`; } | |
| function populateDatasetControls() { | |
| if(!snapshot)return; | |
| const entries=datasetEntries(),selected=$('dataset').value||'all',measured=new Set(records.map(record=>record.dataset)),groups=new Map(); | |
| for(const entry of entries){const group=datasetCategory(entry);if(!groups.has(group))groups.set(group,[]);groups.get(group).push(entry);datasets.set(datasetKey(entry),entry);} | |
| $('dataset').innerHTML='<option value="all">All measured datasets</option>'+[...groups].map(([group,items])=>`<optgroup label="${escape(group)}">${items.sort((a,b)=>datasetKey(a).localeCompare(datasetKey(b))).map(entry=>{const key=datasetKey(entry),label=entry.label&&entry.label!==key?`${entry.label} (${key})`:key;return `<option value="${escape(key)}">${thulabDatasetUrl(entry)?'🏆 ':''}${escape(label)}${measured.has(key)?'':' · No published measurements'}</option>`;}).join('')}</optgroup>`).join(''); | |
| const requestedIsValid=!requestedDatasetApplied&&requestedDataset&&[...$('dataset').options].some(option=>option.value===requestedDataset); | |
| $('dataset').value=requestedIsValid?requestedDataset:[...$('dataset').options].some(option=>option.value===selected)?selected:'all'; | |
| if(requestedIsValid)requestedDatasetApplied=true; | |
| const groupSelect=$('dataset-group-filter'),previousGroup=groupSelect.value||'all',categories=[...groups.keys()]; | |
| groupSelect.innerHTML='<option value="all">All groups</option>'+categories.map(group=>`<option value="${escape(group)}">${escape(group)} (${groups.get(group).length})</option>`).join(''); | |
| groupSelect.value=categories.includes(previousGroup)?previousGroup:'all'; | |
| } | |
| function renderDatasetCatalog() { | |
| const container=$('dataset-catalog'),status=$('dataset-catalog-status');if(!container||!status||!snapshot)return; | |
| const all=datasetEntries(),query=$('dataset-catalog-search').value.trim().toLowerCase(),group=$('dataset-group-filter').value,measured=new Set(records.map(record=>record.dataset)); | |
| const visible=all.filter(entry=>(group==='all'||datasetCategory(entry)===group)&&(!query||datasetSearchText(entry).includes(query))),groups=new Map(); | |
| for(const entry of visible){const category=datasetCategory(entry);if(!groups.has(category))groups.set(category,[]);groups.get(category).push(entry);} | |
| const measuredVisible=visible.filter(entry=>measured.has(datasetKey(entry))).length,thulabVisible=visible.filter(entry=>thulabDatasetUrl(entry)).length; | |
| status.textContent=`${visible.length} of ${all.length} datasets shown · ${thulabVisible} THULab-hosted · ${measuredVisible} shown entries have published measurements · rankings use ${measured.size} measured datasets`; | |
| if(datasetCatalogError&&!all.length){container.innerHTML=`<p class="documentation-error">${escape(datasetCatalogError.message)}</p>`;return;} | |
| container.innerHTML=visible.length?[...groups].map(([category,entries])=>`<section class="dataset-category"><h3>${escape(category)} <span>${entries.length}</span></h3><div class="dataset-list">${entries.sort((a,b)=>datasetKey(a).localeCompare(datasetKey(b))).map(entry=>renderDatasetEntry(entry,measured.has(datasetKey(entry)))).join('')}</div></section>`).join(''):'<p class="documentation-empty">No dataset matches this search and group filter.</p>'; | |
| for(const button of container.querySelectorAll('[data-dataset-key]'))button.addEventListener('click',()=>{$('dataset').value=button.dataset.datasetKey;updateUrlState();refresh();renderDatasetCatalog();$('leaderboard-wrap').scrollIntoView({block:'nearest'});}); | |
| } | |
| function renderDatasetEntry(entry,isMeasured) { | |
| const key=datasetKey(entry),label=publicText(entry.label,key),rows=number(entry.row_count),payload=humanBytes(entry.size_bytes),metadata=[rows===0?'Empty dataset':rows!==null?`${countFmt(rows)} rows`:'',number(entry.column_count)!==null?`${countFmt(entry.column_count)} columns`:'',number(entry.numeric_column_count)!==null?`${countFmt(entry.numeric_column_count)} numeric`:'',payload?`${payload} numeric payload`:'' ].filter(Boolean),sourceUrl=safeHttpUrl(entry.source_url),datasetUrl=safeHttpUrl(entry.dataset_url),thulabUrl=thulabDatasetUrl(entry),source=publicText(entry.source,'Source'),snapshotDiff=entry.published_result_row_count_matches_catalog===false; | |
| return `<article class="dataset-entry ${isMeasured?'measured':'pending'} ${state().dataset===key?'selected':''}"><button type="button" data-dataset-key="${escape(key)}"><span><strong>${escape(label)}</strong>${label!==key?`<small>${escape(key)}</small>`:''}</span><span class="dataset-state">${isMeasured?'Measured':'No published measurements'}</span></button>${thulabUrl?`<div class="dataset-affiliations">${thulabDatasetBadge(entry,key)}</div>`:''}${metadata.length?`<p>${metadata.map(escape).join(' · ')}</p>`:''}${entry.current_input_issue?`<p class="dataset-snapshot-note">Corrected-input retest pending: ${escape(entry.current_input_issue)}</p>`:''}${snapshotDiff?'<p class="dataset-snapshot-note">Published measurements use an earlier prepared snapshot.</p>':''}<div class="dataset-links">${sourceUrl?`<a href="${escape(sourceUrl)}" target="_blank" rel="noopener noreferrer">${escape(source)} ↗</a>`:entry.source?`<span class="dataset-source">${escape(source)}</span>`:''}${datasetUrl&&datasetUrl!==sourceUrl&&!thulabUrl?`<a href="${escape(datasetUrl)}" target="_blank" rel="noopener noreferrer">Dataset files ↗</a>`:''}</div></article>`; | |
| } | |
| async function loadDatasetCatalog() { | |
| try { | |
| const response=await fetch(clean200AssetUrl('dataset-catalog.json.gz'),{cache:'no-cache'});if(!response.ok)throw new Error(`Dataset catalog request returned ${response.status}.`); | |
| const compressed=await response.arrayBuffer();if(await sha256Hex(compressed)!==DATASET_CATALOG_GZIP_SHA256)throw new Error('Dataset catalog compressed SHA differs.');const bytes=await gunzipBuffer(compressed,'The dataset catalog');if(await sha256Hex(bytes)!==DATASET_CATALOG_SHA256)throw new Error('Dataset catalog SHA differs.');const catalog=JSON.parse(new TextDecoder().decode(bytes));if(!catalog||!Array.isArray(catalog.datasets)||!catalog.summary)throw new Error('Dataset catalog has an invalid schema.');datasetCatalog=filterProject200Catalog(catalog); | |
| } catch(error) { datasetCatalogError=error instanceof Error?error:new Error('Dataset catalog is unavailable.'); } | |
| if(snapshot){populateDatasetControls();renderDatasetCatalog();renderAbout();} | |
| } | |
| function renderAbout() { | |
| const b=snapshot.benchmark||{},s=snapshot.source||{},c=snapshot.coverage||{}; | |
| const notes=['The active benchmark scope contains 200 datasets with accepted numerical measurements for 85 compression algorithms and 97 active operator implementations. Unsupported and N/A outcomes are explicit and never participate in rankings.',b.aggregation_note,b.selection_note,...(b.notes||[]),...(b.measurement_boundaries||[])].filter(Boolean); | |
| $('methodology').innerHTML=notes.map(n=>`<p class="notice">${escape(n)}</p>`).join(''); | |
| const definitions=b.metric_definitions||{};if(Object.keys(definitions).length)$('methodology').innerHTML+=`<dl class="definitions">${Object.entries(definitions).map(([k,v])=>`<div><dt>${escape(k.replaceAll('_',' '))}</dt><dd>${escape(typeof v==='string'?v:JSON.stringify(v))}</dd></div>`).join('')}</dl>`; | |
| const exclusions=c.exclusions||c.excluded_datasets||snapshot.exclusions||[]; | |
| const catalogCount=number(datasetCatalog?.summary?.dataset_count??c.catalog_dataset_count)??datasetEntries().length,measuredCount=number(datasetCatalog?.summary?.published_result_dataset_count??datasetCatalog?.summary?.published_measurement_dataset_count??datasetCatalog?.summary?.measured_dataset_count??c.measured_dataset_count)??new Set(records.map(r=>r.dataset)).size; | |
| const terminal=c.native86_terminal_coverage||{}; | |
| const info={ 'Historical base exported':snapshot.exported_at||s.exported_at||'Unavailable in snapshot','Dataset catalog':`${catalogCount} datasets; ${measuredCount} currently have published measurements and participate in rankings`,'Published measurement archive':terminal.expected_pair_count?`${terminal.observed_pair_count} / ${terminal.expected_pair_count} dataset-method pairs; ${terminal.numeric_pair_count??0} contain published numeric aggregates, ${terminal.not_applicable_pair_count??0} are explicit N/A, ${terminal.problem_pair_count??0} ended with a failure status`:'See manifest and terminal coverage download','Dataset scope generated':s.generated_at||'Unavailable in snapshot', 'Source checkout':s.git_commit||'Unavailable in snapshot','Source files':`${s.source_files?.length??0} metadata inputs and ${s.result_csv_files_used?.length??0} result CSVs (hashes in manifest)`,'Result entries across scopes':`${records.length} (scope slices can reuse a measurement)`,'Worktree source state':s.worktree_dirty_inputs?.length?'Includes current local changes; input file hashes identify the published snapshot.':'See manifest for source file hashes.','Runtime environment':b.hardware||'Hardware details are unavailable in this exported result snapshot.','Lossless evidence':b.roundtrip_evidence||'Lossless-design method filter from the source project; per-run round-trip verification is unavailable here.'}; | |
| $('provenance').innerHTML=`<table class="provenance-table"><tbody>${Object.entries(info).map(([k,v])=>`<tr><th>${escape(k)}</th><td class="source-code">${escape(v)}</td></tr>`).join('')}</tbody></table>${exclusions.length?`<h3>Excluded or unavailable results</h3><p class="source-code">${escape(typeof exclusions==='string'?exclusions:JSON.stringify(exclusions))}</p>`:''}`; | |
| } | |
| function decodeCompactRecord(row,index) { | |
| const t=snapshot.record_tables; | |
| return {_compact_index:index,dataset:t.datasets[row[0]],scope:t.scopes[row[1]],runtime:t.runtimes[row[2]],comparison_profile:t.comparison_profiles[row[3]],family:t.families[row[4]],method:t.configurations[row[5]],algorithm_variant:t.configurations[row[5]],compression_rate:row[6],compression_time_ns_per_point:row[7],decompression_time_ns_per_point:row[8],original_size_bytes:row[9],compressed_size_bytes:row[10],timing_column_count:row[11],timing_aggregation:t.timing_aggregations[row[12]],eligible_column_set_sha256:t.support_sets[row[13]],measurement_status:t.measurement_statuses[row[14]],timing_profile_status:t.timing_statuses[row[15]],binary_sha256:t.binary_hashes[row[16]]}; | |
| } | |
| function applyCppLatestView() { | |
| if(!cppLatestView||cppLatestView.schema!=='compressionbenchmark-cpp-latest-view-v1'||cppLatestView.status!=='built_from_accepted_clean200_results_v1')throw new Error('The combined C++ selection sidecar has an invalid schema or status.'); | |
| const compact=snapshot.compact_records;if(!Array.isArray(compact))throw new Error('The SHA-bound compact record table is missing.'); | |
| if(cppLatestView.baseline?.compact_record_count!==153219||compact.length!==191299)throw new Error('The Clean200 compact-record prefix or final count is invalid.'); | |
| if(snapshot.source_data_sha256!=='18a96a681dbddfe1aef51108f1399f836b970391891ed1d051bc6cdce81bf7fe'||cppLatestView.cpp?.counts?.clean200_accepted_dataset_family_pair_count!==17000)throw new Error('The Clean200 selection sidecar binding is invalid.'); | |
| const selectors=cppLatestView.selectors;if(!Array.isArray(selectors)||selectors.join('\0')!=='cpp\0java\0python')throw new Error('The combined view must expose exactly C++, Java, and Python.'); | |
| const selected=cppLatestView.cpp?.selected_rows;if(!Array.isArray(selected))throw new Error('The combined C++ selected-row index is missing.'); | |
| const seen=new Set(),cpp=[]; | |
| for(const item of selected){ | |
| const index=item?.raw_compact_index; | |
| if(!Number.isInteger(index)||index<0||index>=compact.length||seen.has(index))throw new Error('The combined C++ selected-row indices are invalid or duplicated.'); | |
| seen.add(index); | |
| const decoded=decodeCompactRecord(compact[index],index); | |
| if(['java','python'].includes(decoded.comparison_profile)||decoded.comparison_profile!==item.source_comparison_profile||decoded.runtime!==item.source_runtime||decoded.family!==item.source_family)throw new Error(`Combined C++ provenance mismatch at compact row ${index}.`); | |
| if(typeof item.canonical_family!=='string'||!item.canonical_family||typeof item.source_host!=='string'||!item.source_host)throw new Error(`Combined C++ identity metadata is incomplete at compact row ${index}.`); | |
| const decodedTimingAdmitted=/^timing_admitted_/i.test(String(decoded.timing_profile_status??'')); | |
| if(Boolean(item.timing_admitted)!==decodedTimingAdmitted||!['numeric','partial_numeric'].includes(item.pair_status))throw new Error(`Combined C++ admission metadata mismatch at compact row ${index}.`); | |
| cpp.push({...decoded,comparison_profile:'cpp',family:item.canonical_family,source_family:item.source_family,source_comparison_profile:item.source_comparison_profile,source_runtime:item.source_runtime,source_execution_host:item.source_host,selection_authority:item.authority,pair_status:item.pair_status,timing_contract:item.timing_contract,timing_execution_environment:item.timing_execution_environment,timing_schedule:item.timing_schedule,timing_threads:item.timing_threads,timing_block_size_values:item.timing_block_size_values,timing_sample_statistic:item.timing_sample_statistic,timing_denominator:item.timing_denominator,timing_measurement_boundary:item.timing_measurement_boundary,overall_column_mean_rate:number(item.overall_column_mean_rate),overall_column_mean_compression_time:number(item.overall_column_mean_compression_time),overall_column_mean_decompression_time:number(item.overall_column_mean_decompression_time)}); | |
| } | |
| const ledger=cppLatestView.cpp?.pair_ledger;if(!Array.isArray(ledger))throw new Error('The combined C++ pair ledger is missing.'); | |
| for(const decision of ledger)if(!['numeric','partial_numeric'].includes(decision.status)&&Array.isArray(decision.selected_raw_indices)&&decision.selected_raw_indices.length)throw new Error('A terminal N/A or unsupported decision attempts to fall back to an older numeric row.'); | |
| const expectedTiming=new Set(cppLatestView.cpp?.timing_subset?.selected_raw_indices||[]),actualTiming=new Set(selected.filter(item=>item.timing_admitted).map(item=>item.raw_compact_index)); | |
| if(expectedTiming.size!==actualTiming.size||[...expectedTiming].some(index=>!actualTiming.has(index)))throw new Error('The combined C++ admitted-timing index does not match selected-row metadata.'); | |
| const imported=compact.map(decodeCompactRecord).filter(row=>['java','python'].includes(row.comparison_profile)).map(row=>{ | |
| const publishedHost=snapshot.benchmark?.runtime_hosts?.[row.comparison_profile]; | |
| return {...row,source_family:row.family,source_comparison_profile:row.comparison_profile,source_runtime:row.runtime,source_execution_host:typeof publishedHost==='string'?publishedHost.trim():''}; | |
| }); | |
| snapshot.dataset_results=[...cpp,...imported];delete snapshot.compact_records; | |
| } | |
| function init() { | |
| applyCppLatestView(); | |
| snapshot=applyProject200Scope(snapshot); | |
| for(const m of snapshot.methods||[]) { const method=typeof m==='string'?{name:m}:m;methods.set(method.name??method.method,method);for(const c of method.configurations||[])methods.set(c.algorithm_variant,{...method,name:c.algorithm_variant,family:method.name}); } | |
| for(const d of snapshot.datasets||[])datasets.set(d.key??d.dataset,d); | |
| records=(snapshot.dataset_results||snapshot.records||[]).map(normalizeRecord).filter(r=>r.method&&r.dataset&&r.compression_rate>0); | |
| for(const r of records)if(!methods.has(r.method))methods.set(r.method,{name:r.method,family:r.family}); | |
| const runtimeOrder=['cpp','java','python']; | |
| const runtimes=[...new Set(records.map(r=>r.runtime))].sort((a,b)=>{const ai=runtimeOrder.indexOf(a),bi=runtimeOrder.indexOf(b);return (ai<0?runtimeOrder.length:ai)-(bi<0?runtimeOrder.length:bi)||a.localeCompare(b);}); | |
| $('runtime').innerHTML=runtimes.map(r=>`<option value="${escape(r)}">${escape(runtimeName(r))}</option>`).join(''); | |
| const requestedProfile=new URLSearchParams(location.search).get('profile'); | |
| if(runtimes.includes(requestedProfile))$('runtime').value=requestedProfile; | |
| else if(requestedProfile&&requestedProfile!=='cpp'){legacyProfileRequested=requestedProfile;$('runtime').value='cpp';} | |
| else $('runtime').value=runtimes.includes(DEFAULT_PROFILE)?DEFAULT_PROFILE:runtimes[0]; | |
| syncInputContractControls(); | |
| populateDatasetControls(); | |
| populateFamilyControl(); | |
| $('runtime-count').textContent=runtimes.length;$('record-count').textContent=countFmt(new Set(records.map(r=>`${r.runtime}\0${r.family}\0${r.method}`)).size); | |
| $('snapshot').textContent='Snapshot sources and result versions are recorded in the release manifest.';$('footer-snapshot').textContent=`Source inputs documented in the manifest`; | |
| $('column-options').innerHTML=cols.map(c=>`<label><input type="checkbox" data-column="${c.key}" ${defaultColumnVisible($('runtime').value,c)?'checked':''}>${escape(c.label)}</label>`).join(''); | |
| $('weights').innerHTML=WEIGHT_TENTHS.map(w=>`<option value="${w.join(',')}" ${w.join(',')==='4,3,3'?'selected':''}>a = ${(w[0]/10).toFixed(1)} · b = ${(w[1]/10).toFixed(1)} · c = ${(w[2]/10).toFixed(1)}</option>`).join(''); | |
| $('weights').addEventListener('change',refresh); | |
| for(const input of $('column-options').querySelectorAll('input'))input.addEventListener('change',()=>{const column=cols.find(c=>c.key===input.dataset.column);touchedColumns.add(column.key);column.visible=input.checked;renderTable();}); | |
| $('show-unavailable-columns').addEventListener('change',renderTable); | |
| $('runtime').addEventListener('change',()=>{legacyProfileRequested='';syncInputContractControls();populateFamilyControl();refresh();updateUrlState();}); | |
| for(const id of ['dtype','precision'])$(id).addEventListener('change',()=>{syncInputContractControls();populateFamilyControl();refresh();}); | |
| for(const id of ['family','row-mode','complete-only'])$(id).addEventListener('change',refresh);$('dataset').addEventListener('change',()=>{updateUrlState();refresh();if(activeTab==='dataset')renderDatasetCatalog();});$('search').addEventListener('input',refresh);$('chart-metric').addEventListener('change',renderChart);$('download').addEventListener('click',csv); | |
| $('reset').addEventListener('click',()=>{$('runtime').value=runtimes.includes(DEFAULT_PROFILE)?DEFAULT_PROFILE:runtimes[0];$('dtype').value='overall';$('precision').value='all';populateFamilyControl();$('dataset').value='all';$('row-mode').value='family';$('search').value='';$('family').value='all';$('weights').value='4,3,3';$('complete-only').checked=false;$('show-unavailable-columns').checked=false;touchedColumns.clear();for(const column of cols)column.visible=column.defaultVisible;legacyProfileRequested='';selectedMethod=null;$('method-detail').hidden=true;sort={key:'compression_rate',direction:1};setTab(activeTab);}); | |
| for(const tab of document.querySelectorAll('[data-tab]'))tab.addEventListener('click',()=>setTab(tab.dataset.tab)); | |
| $('method-doc-search').addEventListener('input',renderMethodDocumentation);$('operator-doc-search').addEventListener('input',renderOperatorDocumentation);$('operator97-dataset').addEventListener('change',renderOperator97);$('operator97-search').addEventListener('input',renderOperator97);$('operator97-download-csv').addEventListener('click',downloadOperator97Csv);$('dataset-catalog-search').addEventListener('input',renderDatasetCatalog);$('dataset-group-filter').addEventListener('change',renderDatasetCatalog); | |
| renderAbout();renderDocumentationViews();renderDatasetCatalog();setTab(location.hash.slice(1)||(requestedDataset&&$('dataset').value===requestedDataset?'dataset':'overall')); | |
| document.documentElement.dataset.ready='true'; | |
| } | |
| function updateUrlState() { | |
| const url=new URL(location.href);url.hash=activeTab; | |
| const profile=$('runtime')?.value;if(profile)url.searchParams.set('profile',profile); | |
| const selected=$('dataset')?.value; | |
| if(selected&&selected!=='all')url.searchParams.set('dataset',selected);else url.searchParams.delete('dataset'); | |
| history.replaceState(null,'',`${url.pathname}${url.search}${url.hash}`); | |
| } | |
| function setupTheme() { | |
| let stored;try{stored=localStorage.getItem('thulab-theme');}catch{} | |
| const query=new URLSearchParams(location.search).get('__theme'); | |
| const theme=stored||(['dark','light'].includes(query)?query:matchMedia('(prefers-color-scheme:dark)').matches?'dark':'light'); | |
| document.documentElement.dataset.theme=theme;$('theme').textContent=theme==='dark'?'Light mode':'Dark mode'; | |
| $('theme').addEventListener('click',()=>{const next=document.documentElement.dataset.theme==='dark'?'light':'dark';document.documentElement.dataset.theme=next;$('theme').textContent=next==='dark'?'Light mode':'Dark mode';try{localStorage.setItem('thulab-theme',next);}catch{}}); | |
| } | |
| setupTheme(); | |
| void loadReferenceCatalog(); | |
| void loadOperatorEffect(); | |
| void loadOperator97(); | |
| void loadDatasetCatalog(); | |
| async function sha256Hex(buffer){const digest=await crypto.subtle.digest('SHA-256',buffer);return [...new Uint8Array(digest)].map(byte=>byte.toString(16).padStart(2,'0')).join('');} | |
| async function gunzipBuffer(buffer,label){if(typeof DecompressionStream!=='function')throw new Error(`${label} requires browser gzip decompression support.`);try{return await new Response(new Blob([buffer]).stream().pipeThrough(new DecompressionStream('gzip'))).arrayBuffer();}catch(error){throw new Error(`${label} could not be decompressed: ${error instanceof Error?error.message:String(error)}`);}} | |
| function patchTableIndex(tables,name,value){let index=tables[name].indexOf(value);if(index<0){tables[name].push(value);index=tables[name].length-1;}return index;} | |
| function applyUiIncrementalPatch(base,patch){ | |
| if(patch?.schema!=='compressionbenchmark-ui-incremental-patch-v1'||patch?.status!=='complete'||patch.base_compact_record_count!==base.compact_records.length)throw new Error('The UI incremental patch contract differs.'); | |
| const t=base.record_tables; | |
| for(const r of patch.additions)base.compact_records.push([patchTableIndex(t,'datasets',r.dataset),patchTableIndex(t,'scopes',r.scope),patchTableIndex(t,'runtimes',r.runtime),patchTableIndex(t,'comparison_profiles',r.comparison_profile),patchTableIndex(t,'families',r.family),patchTableIndex(t,'configurations',r.configuration),r.compression_rate,r.compression_time,r.decompression_time,r.original_bytes,r.compressed_bytes,r.timing_column_count,patchTableIndex(t,'timing_aggregations',r.timing_aggregation),patchTableIndex(t,'support_sets',r.support_set),patchTableIndex(t,'measurement_statuses',r.measurement_status),patchTableIndex(t,'timing_statuses',r.timing_status),patchTableIndex(t,'binary_hashes',r.binary_hash)]); | |
| for(const [key,value] of Object.entries(patch.final_metadata))base[key]=value; | |
| if(base.compact_records.length!==patch.final_scientific_compact_record_count)throw new Error('The reconstructed UI row count differs.');return base; | |
| } | |
| function applySideIncrementalPatch(base,patch){ | |
| if(patch?.schema!=='compressionbenchmark-cpp-latest-view-patch-v1'||patch?.status!=='complete')throw new Error('The C++ selection patch contract differs.'); | |
| const targets=new Set(patch.target_pair_keys),out=JSON.parse(JSON.stringify(base)); | |
| out.status=patch.final_status;out.baseline=patch.final_baseline;out.identity_contract.atomicity=patch.identity_atomicity;out.precedence.push(patch.precedence_entry);out.receipts[patch.receipt_name]=patch.receipt; | |
| out.cpp.selected_rows=out.cpp.selected_rows.filter(item=>!targets.has(`${decodeCompactRecord(snapshot.compact_records[item.raw_compact_index],item.raw_compact_index).dataset} ${item.canonical_family}`)).concat(patch.replacement_selected_rows).sort((a,b)=>a.raw_compact_index-b.raw_compact_index); | |
| out.cpp.pair_ledger=out.cpp.pair_ledger.filter(item=>!targets.has(`${item.dataset} ${item.canonical_family}`)).concat(patch.replacement_pair_ledger).sort((a,b)=>a.dataset.localeCompare(b.dataset)||a.canonical_family.localeCompare(b.canonical_family)); | |
| out.cpp.counts=patch.final_counts;out.cpp.timing_subset=patch.final_timing_subset;out.warnings.push(patch.warning); | |
| if(out.cpp.selected_rows.length!==patch.final_selected_count||out.cpp.pair_ledger.length!==patch.final_pair_ledger_count)throw new Error('The reconstructed C++ selection count differs.');return out; | |
| } | |
| try { | |
| const responses=await Promise.all([fetch(clean200AssetUrl('ui-data-project200.json.gz'),{cache:'no-cache'}),fetch(clean200AssetUrl('cpp-latest-view-project200.json.gz'),{cache:'no-cache'})]); | |
| if(responses.some(response=>!response.ok))throw new Error('The project200 snapshot request failed.'); | |
| const compressed=await Promise.all(responses.map(response=>response.arrayBuffer())); | |
| const expectedCompressed=[UI_DATA_GZIP_SHA256,CPP_LATEST_VIEW_GZIP_SHA256]; | |
| for(let i=0;i<compressed.length;i++)if(await sha256Hex(compressed[i])!==expectedCompressed[i])throw new Error('A compressed project200 input SHA differs.'); | |
| const raw=await Promise.all(compressed.map((value,index)=>gunzipBuffer(value,index===0?'The project200 result snapshot':'The project200 selection sidecar'))); | |
| const expectedRaw=[UI_DATA_SHA256,CPP_LATEST_VIEW_SHA256]; | |
| for(let i=0;i<raw.length;i++)if(await sha256Hex(raw[i])!==expectedRaw[i])throw new Error('A canonical project200 input SHA differs.'); | |
| [snapshot,cppLatestView]=raw.map(value=>JSON.parse(new TextDecoder().decode(value)));init(); | |
| } | |
| catch(e){$('load-error').hidden=false;$('load-error').textContent=`The result snapshot could not be loaded. Please reload the page or download the JSON from the repository. ${e.message}`;$('snapshot').textContent='Snapshot unavailable';$('leaderboard').querySelector('tbody').innerHTML='<tr><td class="empty-cell">Results unavailable.</td></tr>';} | |