Skip to content

apply showRawData option for markdown export #1964

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

Merged
merged 1 commit into from
Aug 14, 2024
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
8 changes: 4 additions & 4 deletions site/frontend/src/pages/compare/compile/compile-page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,15 @@ function refreshQuickLinks() {
quickLinksKey.value += 1;
}

function exportData() {
exportToMarkdown(comparisons.value);
}

const urlParams = getUrlParams();

const quickLinksKey = ref(0);
const filter = ref(loadFilterFromUrl(urlParams, defaultCompileFilter));

function exportData() {
exportToMarkdown(comparisons.value, filter.value.showRawData);
}

const benchmarkMap = createCompileBenchmarkMap(props.data);
const allComparisons = computed(() =>
computeCompileComparisonsWithNonRelevant(
Expand Down
42 changes: 34 additions & 8 deletions site/frontend/src/pages/compare/compile/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,44 @@ import {computeSummary, TestCaseComparison} from "../data";
import {CompileTestCase} from "./common";

export function exportToMarkdown(
comparisons: TestCaseComparison<CompileTestCase>[]
comparisons: TestCaseComparison<CompileTestCase>[],
showRawData: boolean = false
) {
function changesTable(comparisons: TestCaseComparison<CompileTestCase>[]) {
let data =
"| Benchmark | Profile | Scenario | % Change | Significance Factor |\n";
data += "|:---:|:---:|:---:|:---:|:---:|\n";
let columns = [
"Benchmark",
"Profile",
"Scenario",
"% Change",
"Significance Factor",
];
if (showRawData) {
columns.push("Before", "After");
}

const toMarkdownRow = (cells: string[]) => {
return `| ${cells.join(" | ")} |\n`;
};

let data = toMarkdownRow(columns);
data += toMarkdownRow(Array(columns.length).fill(":---:")).replace(
/ /g,
""
);

for (const comparison of comparisons) {
data += `| ${comparison.testCase.benchmark} | ${comparison.testCase.profile} | ${comparison.testCase.scenario} `;
data += `| ${comparison.percent.toFixed(
2
)}% | ${comparison.significanceFactor.toFixed(2)}x\n`;
let cells = [
comparison.testCase.benchmark,
comparison.testCase.profile,
comparison.testCase.scenario,
`${comparison.percent.toFixed(2)}%`,
`${comparison.significanceFactor.toFixed(2)}x`,
];
if (showRawData) {
cells.push(comparison.datumA.toString(), comparison.datumB.toString());
}

data += toMarkdownRow(cells);
}

return data;
Expand Down
Loading