@@ -2,18 +2,44 @@ import {computeSummary, TestCaseComparison} from "../data";
22import { CompileTestCase } from "./common" ;
33
44export function exportToMarkdown (
5- comparisons : TestCaseComparison < CompileTestCase > [ ]
5+ comparisons : TestCaseComparison < CompileTestCase > [ ] ,
6+ showRawData : boolean = false
67) {
78 function changesTable ( comparisons : TestCaseComparison < CompileTestCase > [ ] ) {
8- let data =
9- "| Benchmark | Profile | Scenario | % Change | Significance Factor |\n" ;
10- data += "|:---:|:---:|:---:|:---:|:---:|\n" ;
9+ let columns = [
10+ "Benchmark" ,
11+ "Profile" ,
12+ "Scenario" ,
13+ "% Change" ,
14+ "Significance Factor" ,
15+ ] ;
16+ if ( showRawData ) {
17+ columns . push ( "Before" , "After" ) ;
18+ }
19+
20+ const toMarkdownRow = ( cells : string [ ] ) => {
21+ return `| ${ cells . join ( " | " ) } |\n` ;
22+ } ;
23+
24+ let data = toMarkdownRow ( columns ) ;
25+ data += toMarkdownRow ( Array ( columns . length ) . fill ( ":---:" ) ) . replace (
26+ / / g,
27+ ""
28+ ) ;
1129
1230 for ( const comparison of comparisons ) {
13- data += `| ${ comparison . testCase . benchmark } | ${ comparison . testCase . profile } | ${ comparison . testCase . scenario } ` ;
14- data += `| ${ comparison . percent . toFixed (
15- 2
16- ) } % | ${ comparison . significanceFactor . toFixed ( 2 ) } x\n`;
31+ let cells = [
32+ comparison . testCase . benchmark ,
33+ comparison . testCase . profile ,
34+ comparison . testCase . scenario ,
35+ `${ comparison . percent . toFixed ( 2 ) } %` ,
36+ `${ comparison . significanceFactor . toFixed ( 2 ) } x` ,
37+ ] ;
38+ if ( showRawData ) {
39+ cells . push ( comparison . datumA . toString ( ) , comparison . datumB . toString ( ) ) ;
40+ }
41+
42+ data += toMarkdownRow ( cells ) ;
1743 }
1844
1945 return data ;
0 commit comments