@@ -1561,6 +1561,48 @@ sub summarizeRun {
1561
1561
}
1562
1562
1563
1563
1564
+ # Write CSV Headers.
1565
+ # e.g.: "Concurrency,Dhrystone 2 using register variables,Double-Precision Whetstone"
1566
+ #
1567
+ sub summarizeRunCsvHeader {
1568
+ my ( $results , $reportFd ) = @_ ;
1569
+
1570
+ # First col is for Concurrency value.
1571
+ printf $reportFd " Concurrency" ;
1572
+
1573
+ # Write CSV Headers of test.
1574
+ foreach my $bench (@{$results -> {' list' }}) {
1575
+ my $bresult = $results -> {$bench };
1576
+ printf $reportFd " ,%s " , $bresult -> {' msg' };
1577
+ }
1578
+ printf $reportFd " \n " ;
1579
+ }
1580
+
1581
+ # Write CSV data rows per concurrency as "./Run -c 1 -c 2".
1582
+ # e.g.: 1,33526940.9,3623.9
1583
+ # 2,30386997.8,3678.8
1584
+ # 4,31439797.3,3781.4
1585
+ # 8,32872262.9,3826.2
1586
+ sub summarizeRunCsvRows {
1587
+ my ( $results , $reportFd ) = @_ ;
1588
+
1589
+ # Write concurrency value.
1590
+ printf $reportFd " %d " , $results -> {' copies' };
1591
+
1592
+ # Write test results.
1593
+ my $isFirstColumn = 1;
1594
+ foreach my $bench (@{$results -> {' list' }}) {
1595
+ my $bresult = $results -> {$bench };
1596
+
1597
+ printf $reportFd " ,%.1f" , $bresult -> {' score' };
1598
+ $isFirstColumn = 0;
1599
+ }
1600
+
1601
+ printf $reportFd " \n " ;
1602
+ }
1603
+
1604
+
1605
+
1564
1606
# ###########################################################################
1565
1607
# HTML REPORTS
1566
1608
# ###########################################################################
@@ -1854,13 +1896,26 @@ sub main {
1854
1896
# Generate unique file names for the report and log file.
1855
1897
my $reportFile = logFile($systemInfo );
1856
1898
my $reportHtml = $reportFile . " .html" ;
1899
+ my $reportCsv = $reportFile . " .csv" ;
1857
1900
my $logFile = $reportFile . " .log" ;
1858
1901
1902
+ # If defined "UB_OUTPUT_CSV" on Environment, output csv file.
1903
+ my $ubOutputCsv = $ENV {" UB_OUTPUT_CSV" };
1904
+ my $isOutputFormatCsv = defined ($ubOutputCsv ) && $ubOutputCsv eq " true" ;
1905
+ # If write CSV, header needs only once.
1906
+ my $is_csv_header_written = 0;
1907
+
1859
1908
# Open the log file for writing.
1860
1909
open (my $reportFd , " >" , $reportFile ) ||
1861
1910
die (" Run: can't write to $reportFile \n " );
1862
1911
open (my $reportFd2 , " >" , $reportHtml ) ||
1863
1912
die (" Run: can't write to $reportHtml \n " );
1913
+ my $reportFd_Csv ;
1914
+ if ($isOutputFormatCsv ) {
1915
+ open ($reportFd_Csv , " >" , $reportCsv ) ||
1916
+ die (" Run: can't write to $reportCsv \n " );
1917
+ }
1918
+
1864
1919
printf $reportFd " BYTE UNIX Benchmarks (Version %s )\n\n " , $version ;
1865
1920
runHeaderHtml($systemInfo , $reportFd2 );
1866
1921
@@ -1879,13 +1934,24 @@ sub main {
1879
1934
1880
1935
summarizeRun($systemInfo , $results , $verbose , $reportFd );
1881
1936
summarizeRunHtml($systemInfo , $results , $verbose , $reportFd2 );
1937
+
1938
+ if ($isOutputFormatCsv ) {
1939
+ if ( $is_csv_header_written == 0 ) {
1940
+ summarizeRunCsvHeader($results , $reportFd_Csv );
1941
+ $is_csv_header_written = 1;
1942
+ }
1943
+ summarizeRunCsvRows($results , $reportFd_Csv );
1944
+ }
1882
1945
}
1883
1946
1884
1947
runFooterHtml($reportFd2 );
1885
1948
1886
1949
# Finish the report.
1887
1950
close ($reportFd );
1888
1951
close ($reportFd2 );
1952
+ if ($isOutputFormatCsv ) {
1953
+ close ($reportFd_Csv );
1954
+ }
1889
1955
1890
1956
# Display the report, if not in quiet mode.
1891
1957
if ($verbose > 0) {
0 commit comments