Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single place to copy all macros #729

Merged
merged 4 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions infra/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,6 @@ def make_macros(profile, benchmark_suites, output_file):
# report the number of benchmarks in the profile
out.write(format_latex_macro("NumBenchmarksAllSuites", len(dedup([b.get('benchmark') for b in profile]))))






Expand Down
9 changes: 1 addition & 8 deletions infra/nightly-resources/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,10 @@ function getDataForBenchmark(benchmark) {
const rowData = {
runMethod: row.runMethod,
mean: { class: "", value: tryRound(mean(cycles)) },
meanVsBaseline: getDifference(cycles, comparisonCycles, mean),
meanVsOtherBranch: getDifference(cycles, comparisonCycles, mean),
min: { class: "", value: tryRound(min_cycles(cycles)) },
minVsBaseline: getDifference(cycles, comparisonCycles, min_cycles),
max: { class: "", value: tryRound(max_cycles(cycles)) },
maxVsBaseline: getDifference(cycles, comparisonCycles, max_cycles),
median: { class: "", value: tryRound(median_cycles(cycles)) },
medianVsBaseline: getDifference(
cycles,
comparisonCycles,
median_cycles,
),
stddev: { class: "", value: tryRound(stddev(cycles)) },
eggccCompileTimeSecs: {
class: "",
Expand Down
30 changes: 9 additions & 21 deletions infra/nightly-resources/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,7 @@ function addTableTo(element, data, title) {
navigator.clipboard.writeText(table);
};

// add a button that copies latex macros for table
const copyMacrosButton = document.createElement("button");
copyMacrosButton.innerText = "Copy Latex Macros";
copyMacrosButton.onclick = () => {
const macros = nestedJsonToLatexMacros(
data,
"name",
"executions",
"runMethod",
);
console.log("macros");
console.log(macros);
navigator.clipboard.writeText(macros);
};

element.appendChild(copyButton);
element.appendChild(copyMacrosButton);

// add a new div for the table
const tableDiv = document.createElement("div");
Expand Down Expand Up @@ -130,18 +114,22 @@ function refreshView() {

// fill in the overall stats table
const overallStats = getOverallStatistics();

console.log("here");
addTableTo(document.getElementById("tables"), overallStats, "Overall Stats");

var latexMacros = "";
latexMacros = latexMacros + jsonToLatexMacros(overallStats, "runMethod", "");

for (const suite of getSuites()) {
const tableData = tableForSuite(suite);
addTableTo(document.getElementById("tables"), tableData, suite + " Stats");
latexMacros =
latexMacros +
nestedJsonToLatexMacros(tableData, "name", "executions", "runMethod");
}

renderWarnings();
refreshChart();
refreshLatexMacros();
refreshLatexMacros(latexMacros);
}

function renderWarnings() {
Expand Down Expand Up @@ -227,10 +215,10 @@ async function buildNightlyDropdown(element, previousRuns, initialIdx) {
select.value = formatRun(previousRuns[initialIdx]);
}

async function refreshLatexMacros() {
async function refreshLatexMacros(tableMacros) {
const latexMacrosTextArea = document.getElementById("latex-macros-text");
const latexMacros = await fetch("nightlymacros.tex").then((r) => r.text());
latexMacrosTextArea.value = latexMacros;
latexMacrosTextArea.value = tableMacros + latexMacros;
}

function addGraphs() {
Expand Down
20 changes: 18 additions & 2 deletions infra/nightly-resources/latex.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,31 @@ function jsonToLatexTable(json) {
return res;
}

// change dashes to underscores
const replenum = {
0: "zero",
1: "one",
2: "two",
3: "three",
4: "four",
5: "five",
6: "six",
7: "seven",
8: "eight",
9: "nine",
};

// remove dashes and underscores, replace numbers with words
function convertStringToValidLatexVar(str) {
// if the str is valid html, get the text content
if (str.includes("<")) {
var div = document.createElement("div");
div.innerHTML = str;
str = div.textContent;
}
return str.replace(/-/g, "_");

const dashes_removed = str.replace(/-/g, "").replace(/_/g, "");

return dashes_removed.replace(/\d/g, (match) => replenum[match]);
}

// convert a javascript array object storing a table
Expand Down
3 changes: 3 additions & 0 deletions infra/nightly-resources/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ function ConvertJsonToTable(
tableClassName,
linkText,
) {
// copy the table right away so we don't mutate it
parsedJson = JSON.parse(JSON.stringify(parsedJson));

//Patterns for links and NULL value
var italic = "<i>{0}</i>";
var link = linkText
Expand Down