mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 11:26:18 -04:00
456d1ba536
Adds a quick perf report feature to `goalc` that lets you compare how much faster / slower it takes to compile the projects, with some simple features like filtering the files, adjusting for how large of a margin of error in the speeds you care about, and which test iteration you want to compare against. This is something I plan to use as I work more in `goalc` as an easy way to track / show the results. ![image](https://github.com/open-goal/jak-project/assets/13153231/26f140c7-66d7-4162-994a-a71061e22857)
42 lines
2.8 KiB
C++
42 lines
2.8 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
|
|
const std::string compiler_report_base =
|
|
"<!doctypehtml><html lang=en><meta charset=UTF-8><meta "
|
|
"content=\"width=device-width,initial-scale=1\"name=viewport><title>OpenGOALc "
|
|
"Report</"
|
|
"title><style>html{font-size:10pt;font-family:sans-serif}table{width:100%;border-collapse:"
|
|
"collapse;margin:20px 0;box-shadow:0 2px 3px rgba(0,0,0,.1)}thead "
|
|
"th{background-color:#4caf50;color:#fff;text-align:left;padding:12px "
|
|
"15px;font-weight:700}tbody tr{border-bottom:1px solid #ddd}tbody td{padding:12px 15px}tbody "
|
|
"tr:nth-child(even){background-color:#f2f2f2}tbody "
|
|
"tr:hover{background-color:#f1f1f1}table{margin:20px 0}</style><canvas height=75vh "
|
|
"id=chart></canvas><br>Compare Against: <select id=compare></select> Accepted Margin of Error "
|
|
"%: <input id=margin type=number value=15>File Regex: <input id=regex><button "
|
|
"onclick=renderData()>Apply</button><table id=table><thead><tr "
|
|
"id=table-head-row><th>File<tbody id=table-body></table><script "
|
|
"src=https://cdn.jsdelivr.net/npm/chart.js></script><script>\n// DATA BEGINS\nconst tests = "
|
|
"[]\n// DATA ENDS\nlet testOrder=[],tableData={};for(const test of "
|
|
"tests)for(const[fileName,fileTime]of(testOrder.push(test.name),document.getElementById("
|
|
"\"compare\").innerHTML+=`<option "
|
|
"value=\"${test.name}\">${test.name}</"
|
|
"option>`,Object.entries(test.files)))Object.keys(tableData).includes(fileName)||(tableData["
|
|
"fileName]={}),tableData[fileName][test.name]=fileTime;const "
|
|
"tableHeadRow=document.getElementById(\"table-head-row\");let tableHeadContents=\"\";for(const "
|
|
"testName of testOrder)tableHeadContents+=`<th>${testName}</th>`;function renderData(){let "
|
|
"e=parseInt(document.getElementById(\"margin\").value)/"
|
|
"100,t=document.getElementById(\"regex\").value;t=\"\"!==t?RegExp(t):void 0;let "
|
|
"a=document.getElementById(\"compare\").value;\"\"!==a&&a||(a=testOrder[0]);let "
|
|
"l=document.getElementById(\"table-body\");for(let[n,d]of(l.innerHTML=\"\",Object.entries("
|
|
"tableData)))if(void 0===t||t.test(n)){var o=`<tr><td>${n}</td>`;for(let r of "
|
|
"testOrder)Object.keys(d).includes(r)?a!==r&&Object.keys(d).includes(a)?d[r]>d[a]*(1+e)?o+=`<"
|
|
"td style=\"background-color: #faa;\">${d[r]}</td>`:d[r]<d[a]*(1-e)?o+=`<td "
|
|
"style=\"background-color: "
|
|
"#c7ffc7;\">${d[r]}</td>`:o+=`<td>${d[r]}</td>`:o+=`<td>${d[r]}</td>`:o+=\"<td>--</"
|
|
"td>\";l.innerHTML+=o+\"</tr>\"}}tableHeadRow.innerHTML+=tableHeadContents,renderData();const "
|
|
"ctx=document.getElementById(\"chart\");new "
|
|
"Chart(ctx,{type:\"bar\",data:{labels:tests.map(e=>e.name),datasets:[{label:\"Total "
|
|
"Time\",data:tests.map(e=>e.total),borderWidth:1}]},options:{scales:{y:{beginAtZero:!0,type:"
|
|
"\"logarithmic\",title:{display:!0,text:\"Seconds\"}}}}});</script>";
|