Merge pull request #4 from ludovic111/offline-benchmark-viewer

Compare game benchmarks offline on Mac, Windows and Linux
This commit is contained in:
Ludovic Marie
2026-10-03 22:10:26 +02:00
committed by GitHub
7 changed files with 205 additions and 4 deletions
+3 -1
View File
@@ -6,7 +6,7 @@ Client-first performance research for Minecraft Java **26.3**, preserving vanill
## Play on your Mac
Download **horizon-mac-starter-0.3.0.zip** from [Releases](https://github.com/ludovic111/minecraft-optimization-lab/releases), extract it and open `Mac-Start.command`. It verifies and installs official universal Prism Launcher in `~/Applications` if needed, then opens the balanced pack import. Sign into Microsoft **inside Prism yourself**. This project needs no credentials.
Download **horizon-mac-starter-0.5.0.zip** from [Releases](https://github.com/ludovic111/minecraft-optimization-lab/releases), extract it and open `Mac-Start.command`. It verifies and installs official universal Prism Launcher in `~/Applications` if needed, then opens the balanced pack import. Sign into Microsoft **inside Prism yourself**. This project needs no credentials.
Use native **Java 25 ARM64**, maximum heap **6144 MiB**, minimum **512 MiB** on your 16 GB M2 Pro. Prism can download Java automatically. Start at 1280×800 or 1920×1200; full Retina resolution is a larger GPU workload. [START-HERE.txt](packs/START-HERE.txt) has details. The same `.mrpack` files import into Prism on Windows and Linux.
@@ -47,6 +47,8 @@ The instance's `horizon-benchmarks/` folder receives JSON/CSV frame and integrat
python3 tools/compare_benchmarks.py baseline-frames.json optimized-frames.json --strict
```
Open `Compare-Benchmarks.html` from the starter ZIP or [the source file](tools/Compare-Benchmarks.html) in your browser to compare without Python. Select each JSON and optionally its matching CSV. It exports summary JSON, flags settings and duration differences, and charts frames by recorded active time or ticks by sample number. It is self-contained and makes no network requests.
The comparison flags captured setting differences, but cannot verify route, world, shader state or cache warm-up. See [validation evidence](docs/playable-validation.md). Software-renderer test FPS is not evidence of a Mac/GPU speedup.
## Build and run
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "horizonlab",
"version": "0.4.0",
"version": "0.5.0",
"name": "Horizon Lab",
"description": "Client frame pacing and server tick measurements for reproducible optimization experiments.",
"authors": [
+8
View File
@@ -80,6 +80,14 @@ MEASURE ON YOUR M2 PRO
5. Repeat at least three times, alternating baseline/optimized. For daily play
turn VSync back on or cap FPS to your display; uncapped FPS spends more power.
COMPARE WITHOUT PYTHON
Open Compare-Benchmarks.html from this ZIP in Safari, Chrome, Firefox or Edge.
Choose one baseline JSON and one candidate JSON from horizon-benchmarks. You can
select each JSON together with its matching CSV to see duration charts. Frame and
tick reports are compared separately. Files stay on your device; the viewer needs
no server, account, installation or network access. Check its settings/route/warm-up
warnings before drawing conclusions. Save comparison exports a summary JSON.
DH changes clouds, chunk fade and transparency to blend its distant renderer;
assess visual differences as well as speed. For collector experiments test
Java 25's -XX:+UseZGC against its default G1 in both profiles; ZGC trades some
+1 -1
View File
@@ -3,7 +3,7 @@
"minecraft": "26.3",
"java_major": 25,
"fabric_loader": "0.19.5",
"pack_version": "0.4.0",
"pack_version": "0.5.0",
"projects": {
"sodium": {
"slug": "sodium",
+183
View File
@@ -0,0 +1,183 @@
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; connect-src 'none'; base-uri 'none'; form-action 'none'">
<title>Horizon Lab — Compare runs</title>
<style>
:root{color-scheme:light;--ink:#192920;--muted:#65726a;--line:#d8ded8;--paper:#f6f7f3;--base:#247854;--candidate:#bc642f}
*{box-sizing:border-box}body{margin:0;background:var(--paper);color:var(--ink);font:15px/1.5 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}main{max-width:1100px;margin:auto;padding:40px 28px 70px}header{display:flex;align-items:center;justify-content:space-between;gap:20px;margin-bottom:26px}.brand{display:flex;align-items:center;gap:11px;font-weight:700}.mark{width:30px;height:30px;background:var(--base);box-shadow:inset 0 -10px #195a3c,inset -10px 0 #2a8c62}.badge{border:1px solid var(--line);padding:4px 10px;border-radius:20px;color:var(--muted);font-size:12px}h1{font-size:clamp(30px,5vw,44px);letter-spacing:-1.3px;line-height:1.15;margin:0 0 10px}h2{font-size:20px;letter-spacing:-.3px;margin:0}p{margin:8px 0;color:var(--muted)}.intro{max-width:750px;margin-bottom:26px}.uploads{display:grid;grid-template-columns:1fr 1fr;gap:18px}.card{background:white;border:1px solid var(--line);border-radius:12px;padding:22px;min-width:0}.card-top{display:flex;gap:9px;align-items:center;margin-bottom:6px}.dot{width:9px;height:9px;border-radius:50%;background:var(--base)}.candidate .dot{background:var(--candidate)}input[type=file]{width:100%;font:inherit;font-size:13px;color:var(--muted);margin-top:15px}input::file-selector-button,button{font:inherit;font-size:13px;background:white;color:var(--ink);border:1px solid var(--line);border-radius:6px;padding:9px 13px;cursor:pointer;margin-right:10px}button:disabled{opacity:.45;cursor:default}input:focus-visible,button:focus-visible{outline:3px solid #80b998;outline-offset:3px}.status{font-size:13px;overflow-wrap:anywhere;margin-top:14px;min-height:20px}.error{color:#a23624}.details{font-size:12px;color:var(--muted);margin:12px 0 0;display:grid;grid-template-columns:100px 1fr;gap:4px 12px;overflow-wrap:anywhere}.details dt,.details dd{margin:0}.details dt{color:var(--ink)}.empty{border:1px dashed var(--line);border-radius:12px;padding:34px;text-align:center;margin-top:22px}.section{margin-top:24px}.section-top{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:14px}.notice{background:#fff8e8;border:1px solid #e7d9af;border-radius:9px;padding:14px 18px;margin-bottom:18px;font-size:13px}.notice p{color:#685c3f;margin:3px 0}.notice ul{padding-left:18px;margin:8px 0}.metrics{overflow:auto;border:1px solid var(--line);border-radius:10px;background:white}table{width:100%;border-collapse:collapse;white-space:nowrap;text-align:right;font-variant-numeric:tabular-nums}th,td{padding:12px 18px;border-bottom:1px solid #edf0ea}th{font-size:12px;font-weight:600;color:var(--muted)}th:first-child,td:first-child{text-align:left}tr:last-child td{border-bottom:0}td:first-child{font-weight:500}td:last-child{font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:13px}.chart{padding:20px;background:white;border:1px solid var(--line);border-radius:10px}.chart svg{display:block;width:100%;height:auto}.chart-tools{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:12px}.chart-tools label{font-size:13px;color:var(--muted)}.chart-info{min-height:22px;font-size:13px;color:var(--muted);font-variant-numeric:tabular-nums}.footnote{font-size:12px;margin-top:15px;max-width:850px}.hidden{display:none!important}footer{margin-top:30px;border-top:1px solid var(--line);padding-top:16px;color:var(--muted);font-size:12px}.legend{display:flex;gap:18px;font-size:12px}.legend span{display:flex;gap:6px;align-items:center}@media(max-width:650px){main{padding:24px 16px 40px}.uploads{grid-template-columns:1fr}.card{padding:18px}header{align-items:flex-start}.section-top{align-items:flex-start}th,td{padding:10px 12px}.badge{white-space:nowrap;font-size:11px}.chart{padding:12px}}
</style>
<main>
<header><div class="brand"><span class="mark" aria-hidden="true"></span>Horizon Lab</div><span class="badge">Offline · files stay on your device</span></header>
<h1>Compare your runs.</h1>
<p class="intro">Choose two Horizon benchmark JSON files from your instance’s <strong>horizon-benchmarks</strong> folder. Add each matching CSV to see frame spikes. Compare frames with frames, or server ticks with server ticks.</p>
<div class="uploads">
<section class="card" aria-labelledby="baselineTitle"><div class="card-top"><span class="dot" aria-hidden="true"></span><h2 id="baselineTitle">Baseline</h2></div><p>Vanilla or your previous configuration.</p><input id="baselineFiles" type="file" multiple accept=".json,.csv" aria-label="Choose baseline JSON and optional CSV"><div id="baselineStatus" class="status" role="status">No report selected.</div><dl id="baselineDetails" class="details"></dl></section>
<section class="card candidate" aria-labelledby="candidateTitle"><div class="card-top"><span class="dot" aria-hidden="true"></span><h2 id="candidateTitle">Candidate</h2></div><p>The configuration you want to evaluate.</p><input id="candidateFiles" type="file" multiple accept=".json,.csv" aria-label="Choose candidate JSON and optional CSV"><div id="candidateStatus" class="status" role="status">No report selected.</div><dl id="candidateDetails" class="details"></dl></section>
</div>
<div id="empty" class="empty"><strong>Your measurements go here.</strong><p>Record with F8 in the game. Keep the world, route, graphics settings and warm-up consistent.</p></div>
<p id="comparisonError" class="error hidden" role="alert"></p>
<section id="results" class="section hidden">
<div class="section-top"><h2 id="resultsTitle">Frame comparison</h2><button id="export" type="button">Save comparison</button></div>
<div id="notices" class="notice"></div>
<div class="metrics"><table aria-label="Benchmark comparison"><thead><tr><th>Measurement</th><th>Baseline</th><th>Candidate</th><th>Change</th></tr></thead><tbody id="metricRows"></tbody></table></div>
<p class="footnote">Changes are candidate versus baseline. Higher FPS is better; lower frame/tick duration, memory and CPU use is usually better. Check workload differences before attributing any change to an optimization.</p>
<section id="chartSection" class="section hidden"><div class="chart"><div class="chart-tools"><h2 id="chartTitle">Frame pacing</h2><label><input id="logScale" type="checkbox" checked> Log scale</label></div><div class="legend"><span><i class="dot"></i>Baseline</span><span><i class="dot" style="background:var(--candidate)"></i>Candidate</span></div><svg id="timeline" viewBox="0 0 960 300" role="img" aria-label="Recorded duration timeline"></svg><div id="chartInfo" class="chart-info">Move over the chart to inspect a time bucket.</div><p id="chartNote" class="footnote"></p></div></section>
<p id="csvHint" class="footnote"></p>
</section>
<footer>No installation, account or network access is needed. Repeat at least three matched runs and test fresh terrain separately from a warm cache. JVM memory excludes some native and GPU allocations.</footer>
</main>
<script>
'use strict';
const SETTINGS=['minecraft','kind','os','os_version','architecture','gpu','graphics_backend','graphics_driver','java_version','heap_max_bytes','framebuffer_width','framebuffer_height','render_distance','simulation_distance','vsync','fps_limit','graphics_preset','ambient_occlusion','improved_transparency','mipmap_levels','entity_distance_scaling','entity_shadows','particles','clouds','cloud_range'];
const state={baseline:null,candidate:null},generation={baseline:0,candidate:0};
let comparison=null,chartData=null;
const $=id=>document.getElementById(id);
const number=value=>typeof value==='number'&&Number.isFinite(value);
const text=(tag,value)=>{const element=document.createElement(tag);element.textContent=String(value);return element;};
const format=value=>number(value)?new Intl.NumberFormat(undefined,{maximumFractionDigits:2}).format(value):'—';
function validateReport(report){
if(!report||report.schema!==1||!['frames','ticks'].includes(report.kind))throw Error('Choose a Horizon frame or server-tick JSON report.');
if(!report.stats||!Number.isInteger(report.stats.count)||report.stats.count<1||report.stats.count>300000)throw Error('This report has no valid sample count. Record focused gameplay with F8 first.');
for(const key of ['meanRate','lowOnePercentRate','meanMs','p50Ms','p95Ms','p99Ms','maxMs']){
if(!number(report.stats[key])||report.stats[key]<0)throw Error('This report has missing or invalid timing measurements.');
}
if(!number(report.elapsed_seconds)||report.elapsed_seconds<=0)throw Error('This report has an invalid recording duration.');
return report;
}
function parseCsv(source,count){
const lines=source.trim().split(/\r?\n/);
if(lines.shift()!=='sample,duration_ns')throw Error('CSV header does not match a Horizon recording.');
if(lines.length!==count||lines.length>300000)throw Error('CSV sample count does not match this JSON report.');
return lines.map((line,index)=>{
const fields=line.split(','),sample=Number(fields[0]),duration=Number(fields[1]);
if(fields.length!==2||sample!==index||!Number.isSafeInteger(duration)||duration<=0)throw Error('CSV contains an invalid sample.');
return duration/1e6;
});
}
function compareReports(a,b){
if(a.kind!==b.kind)throw Error('Compare frame runs with frame runs, or tick runs with tick runs.');
const differences=SETTINGS.filter(key=>JSON.stringify(a[key])!==JSON.stringify(b[key])).map(key=>({setting:key,baseline:a[key]??null,candidate:b[key]??null}));
if(a.kind==='ticks'&&a.peak_players!==b.peak_players)differences.push({setting:'peak_players',baseline:a.peak_players??null,candidate:b.peak_players??null});
const warnings=['World, camera route, shaders and terrain-cache warm-up still need to match. These are not verified by the captured settings.'];
if(Math.abs(a.elapsed_seconds-b.elapsed_seconds)>Math.max(2,Math.min(a.elapsed_seconds,b.elapsed_seconds)*.1))warnings.push('Recording durations differ. Match durations when comparing memory peaks and collection totals.');
for(const [label,r] of [['Baseline',a],['Candidate',b]]){
if(r.elapsed_seconds<60)warnings.push(label+' recording is shorter than 60 seconds. Use longer repeated runs.');
if(r.dropped_samples)warnings.push(label+' exceeded the recording buffer; '+r.dropped_samples+' samples were dropped.');
if(r.kind==='frames'&&r.excluded_frames)warnings.push(label+' excluded '+r.excluded_frames+' menu, paused or unfocused frame starts. Process CPU still spans the whole recording.');
}
const rows=[];
const add=(label,key,unit,scale=1,stats=false)=>{
const av=stats?a.stats[key]:a[key],bv=stats?b.stats[key]:b[key];
if(number(av)&&number(bv))rows.push({label,key,unit,baseline:av/scale,candidate:bv/scale,change_percent:av?100*(bv/av-1):null});
};
if(a.kind==='frames'){
add('Average FPS','meanRate','FPS',1,true);add('Slowest 1% average','lowOnePercentRate','FPS',1,true);
}else{
add('Average tick duration','meanMs','ms',1,true);add('Observed tick rate','observed_ticks_per_second','TPS');
warnings.push('Tick durations exclude scheduler sleep. Observed TPS includes recording time spent paused; tick execution capacity is not TPS.');
}
add('95th percentile duration','p95Ms','ms',1,true);add('99th percentile duration','p99Ms','ms',1,true);add('Longest duration','maxMs','ms',1,true);
add('Sampled peak JVM heap','heap_used_peak_sampled_bytes','MiB',1048576);add('JVM heap at end','heap_used_end_bytes','MiB',1048576);
add('Sampled peak nonheap','nonheap_used_peak_sampled_bytes','MiB',1048576);add('Average process CPU','process_cpu_mean_cores','cores');
if(number(a.gc_time_ms)&&number(b.gc_time_ms)){
const av=a.gc_time_ms/a.elapsed_seconds,bv=b.gc_time_ms/b.elapsed_seconds;
rows.push({label:'GC collection time / second',key:'gc_collection_ms_per_second',unit:'ms/s',baseline:av,candidate:bv,change_percent:av?100*(bv/av-1):null});
}
warnings.push('Memory peaks are sampled and can miss short spikes. Heap/nonheap are not process RSS or GPU memory. CPU includes all Java threads and the integrated server.');
return{kind:a.kind,differences,warnings,metrics:rows};
}
function renderDetails(side){
const entry=state[side],target=$(side+'Details');target.replaceChildren();
if(!entry)return;
const r=entry.report,fields=[['Profile',r.profile||r.label||'Unlabeled'],['Recording',format(r.elapsed_seconds)+' s · '+format(r.stats.count)+' samples'],['Platform',[r.os,r.architecture].filter(Boolean).join(' ')||'Not captured']];
if(r.kind==='frames')fields.push(['Graphics',[r.gpu,r.graphics_backend].filter(Boolean).join(' · ')||'Not captured'],['Window',number(r.framebuffer_width)?r.framebuffer_width+' × '+r.framebuffer_height:'Not captured'],['Experiments','Adaptive: '+(r.adaptive_budget_enabled?'on':'off')+' · precise pacing: '+(r.precise_worker_pacing?'on':'off')]);
for(const [label,value]of fields)target.append(text('dt',label),text('dd',value));
}
async function loadFiles(side,files){
const token=++generation[side];state[side]=null;render();
const status=$(side+'Status');status.classList.remove('error');status.textContent='Reading files…';
try{
const list=Array.from(files),jsonFiles=list.filter(f=>f.name.toLowerCase().endsWith('.json')),csvFiles=list.filter(f=>f.name.toLowerCase().endsWith('.csv'));
if(list.length<1||list.length>2||jsonFiles.length!==1||csvFiles.length>1)throw Error('Choose one JSON report and, optionally, its matching CSV.');
if(jsonFiles[0].size>2*1024*1024||csvFiles.some(f=>f.size>16*1024*1024))throw Error('File is too large for a Horizon recording.');
const report=validateReport(JSON.parse(await jsonFiles[0].text()));
let samples=null,csvWarning=null;
if(csvFiles.length){
try{
if(csvFiles[0].name!==report.samples_file)throw Error('CSV filename does not match this report’s samples file.');
samples=parseCsv(await csvFiles[0].text(),report.stats.count);
const mean=samples.reduce((sum,value)=>sum+value,0)/samples.length;
if(Math.abs(mean-report.stats.meanMs)>Math.max(1e-6,report.stats.meanMs*1e-6)){
samples=null;throw Error('CSV durations do not match the timing summary in this JSON.');
}
}catch(error){csvWarning=error.message;}
}
if(token!==generation[side])return;
state[side]={report,samples,csvWarning,filename:jsonFiles[0].name};
status.textContent=jsonFiles[0].name+(samples?' · CSV loaded':'');
}catch(error){
if(token!==generation[side])return;
status.textContent=error instanceof SyntaxError?'This file is not valid JSON.':error.message;status.classList.add('error');
}
render();
}
function render(){
comparison=null;renderDetails('baseline');renderDetails('candidate');
$('results').classList.add('hidden');$('comparisonError').classList.add('hidden');$('empty').classList.toggle('hidden',!!state.baseline&&!!state.candidate);
if(!state.baseline||!state.candidate)return;
try{comparison=compareReports(state.baseline.report,state.candidate.report);}catch(error){$('comparisonError').textContent=error.message;$('comparisonError').classList.remove('hidden');return;}
$('results').classList.remove('hidden');$('resultsTitle').textContent=comparison.kind==='frames'?'Frame comparison':'Server tick comparison';
const notice=$('notices');notice.replaceChildren(text('strong',comparison.differences.length?'Captured settings differ — check the workload.':'Captured settings match. Check the route and warm-up too.'));
if(comparison.differences.length){const list=document.createElement('ul');for(const d of comparison.differences)list.append(text('li',d.setting+': '+JSON.stringify(d.baseline)+' → '+JSON.stringify(d.candidate)));notice.append(list);}
for(const warning of comparison.warnings)notice.append(text('p',warning));
const rows=$('metricRows');rows.replaceChildren();
for(const metric of comparison.metrics){const row=document.createElement('tr');row.append(text('td',metric.label),text('td',format(metric.baseline)+' '+metric.unit),text('td',format(metric.candidate)+' '+metric.unit),text('td',metric.change_percent===null?'—':(metric.change_percent>=0?'+':'')+format(metric.change_percent)+'%'));rows.append(row);}
const hints=[];for(const side of ['baseline','candidate'])if(state[side].csvWarning)hints.push((side==='baseline'?'Baseline: ':'Candidate: ')+state[side].csvWarning);
if(!state.baseline.samples||!state.candidate.samples)hints.push('Add each matching CSV alongside its JSON to draw both duration timelines.');
$('csvHint').textContent=hints.join(' ');drawChart();
}
function bucketSamples(samples,ticks){
const total=ticks?samples.length:samples.reduce((a,b)=>a+b,0)/1000,bucketSeconds=Math.max(total/1000,ticks?1:.001),buckets=[];
let time=0;
for(const duration of samples){time+=ticks?1:duration/1000;const index=Math.floor(time/bucketSeconds),last=buckets[buckets.length-1];if(last&&last.index===index)last.duration=Math.max(last.duration,duration);else buckets.push({index,time,duration});}
return{total,buckets};
}
function svgElement(tag,attributes){const element=document.createElementNS('http://www.w3.org/2000/svg',tag);for(const [key,value]of Object.entries(attributes))element.setAttribute(key,String(value));return element;}
function drawChart(){
const svg=$('timeline');svg.replaceChildren();chartData=null;
$('chartInfo').textContent='Move over the chart to inspect a bucket.';
const available=!!comparison&&!!state.baseline?.samples&&!!state.candidate?.samples;$('chartSection').classList.toggle('hidden',!available);if(!available)return;
const ticks=comparison.kind==='ticks';
$('chartTitle').textContent=ticks?'Tick durations by sample':'Frame pacing';
$('chartNote').textContent='Each point preserves the longest duration in its bucket. '+(ticks?'Ticks are placed by sample number. Scheduler sleep and pauses are not represented as durations.':'Frames use recorded active time; menus and unfocused intervals are omitted. This is not GPU execution time.');
const a=bucketSamples(state.baseline.samples,ticks),b=bucketSamples(state.candidate.samples,ticks),maxTime=Math.max(a.total,b.total,.001),maxMs=Math.max(...a.buckets.map(p=>p.duration),...b.buckets.map(p=>p.duration),1);
const width=Math.max(320,Math.round(svg.getBoundingClientRect().width));svg.setAttribute('viewBox','0 0 '+width+' 300');
const left=64,right=width-18,top=20,bottom=250,log=$('logScale').checked,transform=x=>log?Math.log1p(x):x;
const x=t=>left+t/maxTime*(right-left),y=ms=>bottom-transform(ms)/transform(maxMs)*(bottom-top);
for(const ms of [0,8.33,16.67,33.33,50,100,250,500,1000,2000,5000,10000,30000,60000]){
if(ms>maxMs)continue;
const line=svgElement('line',{x1:left,x2:right,y1:y(ms),y2:y(ms),stroke:'#e5eae3'});svg.append(line);
const label=svgElement('text',{x:left-8,y:y(ms)+4,'text-anchor':'end',fill:'#65726a','font-size':11});label.textContent=format(ms)+' ms';svg.append(label);
}
const divisions=width<500?3:5;
for(let i=0;i<=divisions;i++){const t=maxTime*i/divisions,label=svgElement('text',{x:x(t),y:bottom+24,'text-anchor':i===0?'start':i===divisions?'end':'middle',fill:'#65726a','font-size':11});label.textContent=ticks?'Tick '+format(Math.round(t)):format(t)+' s';svg.append(label);}
for(const [data,color]of [[a,'#247854'],[b,'#bc642f']])svg.append(svgElement('path',{d:data.buckets.map((point,index)=>(index?'L':'M')+x(point.time).toFixed(2)+' '+y(point.duration).toFixed(2)).join(' '),fill:'none',stroke:color,'stroke-width':1.7,'vector-effect':'non-scaling-stroke'}));
const cursor=svgElement('line',{x1:0,x2:0,y1:top,y2:bottom,stroke:'#192920','stroke-dasharray':'3 3',visibility:'hidden'});svg.append(cursor);chartData={a,b,maxTime,left,right,cursor,ticks,width};
}
$('timeline').addEventListener('pointermove',event=>{
if(!chartData)return;const rect=$('timeline').getBoundingClientRect(),px=(event.clientX-rect.left)/rect.width*chartData.width,t=Math.max(0,Math.min(chartData.maxTime,(px-chartData.left)/(chartData.right-chartData.left)*chartData.maxTime));
chartData.cursor.setAttribute('x1',px);chartData.cursor.setAttribute('x2',px);chartData.cursor.setAttribute('visibility',px>=chartData.left&&px<=chartData.right?'visible':'hidden');
const nearest=data=>{if(t>data.total)return'no samples';let point=data.buckets[0];for(const p of data.buckets){if(Math.abs(p.time-t)<Math.abs(point.time-t))point=p;}return format(point.duration)+' ms';};
$('chartInfo').textContent=(chartData.ticks?'Tick '+format(Math.round(t)):format(t)+' s')+' · baseline '+nearest(chartData.a)+' · candidate '+nearest(chartData.b);
});
$('timeline').addEventListener('pointerleave',()=>{if(chartData)chartData.cursor.setAttribute('visibility','hidden');});
$('logScale').addEventListener('change',drawChart);
window.addEventListener('resize',drawChart);
for(const side of ['baseline','candidate'])$(side+'Files').addEventListener('change',event=>loadFiles(side,event.target.files));
$('export').addEventListener('click',()=>{
if(!comparison)return;const summary={horizon_comparison:1,source_files:{baseline:state.baseline.filename,candidate:state.candidate.filename},...comparison},blob=new Blob([JSON.stringify(summary,null,2)+'\n'],{type:'application/json'}),url=URL.createObjectURL(blob),link=document.createElement('a');link.href=url;link.download='horizon-comparison.json';link.click();setTimeout(()=>URL.revokeObjectURL(url),1000);
});
</script>
</html>
+6 -1
View File
@@ -23,8 +23,12 @@ def main():
client["START-HERE.txt"] = (ROOT / "packs/START-HERE.txt").read_text().replace("@PACK_VERSION@", version).encode()
client["Mac-Start.command"] = (ROOT / "packs/Mac-Start.command").read_text().replace("@PACK_VERSION@", version).encode()
client["LICENSE"] = (ROOT / "LICENSE").read_bytes()
viewer = (ROOT / "tools/Compare-Benchmarks.html").read_bytes()
client["Compare-Benchmarks.html"] = viewer
(ROOT / "dist/Compare-Benchmarks.html").write_bytes(viewer)
build_pack.write_zip(ROOT / "dist" / f"horizon-mac-starter-{version}.zip", client)
server = {"LICENSE": client["LICENSE"], "dist/" + mod.name: mod.read_bytes(),
"Compare-Benchmarks.html": viewer,
"START-HERE.txt": (ROOT / "docs/server-quickstart.txt").read_bytes(),
"research-lock.json": (ROOT / "research-lock.json").read_bytes()}
for name in ["lab.py", "runtime.py", "server.py", "compare_benchmarks.py"]:
@@ -33,9 +37,10 @@ def main():
server["packs/" + name] = (ROOT / "packs" / name).read_bytes()
build_pack.write_zip(ROOT / "dist" / f"horizon-server-starter-{version}.zip", server)
artifacts = sorted(path for path in (ROOT / "dist").glob("*") if version in path.name)
artifacts.append(ROOT / "dist/Compare-Benchmarks.html")
checksums = []
for path in artifacts:
if path.suffix in [".jar", ".mrpack", ".zip"]:
if path.suffix in [".jar", ".mrpack", ".zip", ".html"]:
checksums.append(hashlib.sha256(path.read_bytes()).hexdigest() + " " + path.name)
(ROOT / "dist/SHA256SUMS.txt").write_text("\n".join(checksums) + "\n")
print("Built client/server starters and SHA256SUMS.txt")
+3
View File
@@ -23,6 +23,9 @@ def compare(baseline, candidate):
mismatches = [f"{key}: {baseline.get(key)!r} vs {candidate.get(key)!r}" for key in MATCH_FIELDS
if baseline.get(key) != candidate.get(key)]
warnings = ["World, route, warm-up, shader state and LOD cache must also match; these are not verified by this tool."]
if abs(baseline.get("elapsed_seconds", 0) - candidate.get("elapsed_seconds", 0)) > max(
2, min(baseline.get("elapsed_seconds", 0), candidate.get("elapsed_seconds", 0)) * 0.1):
warnings.append("Recording durations differ; match durations when comparing memory peaks and collection totals.")
for name, report in [("baseline", baseline), ("candidate", candidate)]:
if report.get("dropped_samples", 0):
warnings.append(f"{name} exceeded the recording buffer: {report['dropped_samples']} dropped samples.")