Skip to content

Commit 50f3aad

Browse files
authored
Merge pull request kdlucas#52 from t2-kob/csv_support
Added csv support(score only) by Environment variable.
2 parents 61663da + 918ccbd commit 50f3aad

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

UnixBench/Run

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,6 +1561,48 @@ sub summarizeRun {
15611561
}
15621562

15631563

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+
15641606
############################################################################
15651607
# HTML REPORTS
15661608
############################################################################
@@ -1854,13 +1896,26 @@ sub main {
18541896
# Generate unique file names for the report and log file.
18551897
my $reportFile = logFile($systemInfo);
18561898
my $reportHtml = $reportFile . ".html";
1899+
my $reportCsv = $reportFile . ".csv";
18571900
my $logFile = $reportFile . ".log";
18581901

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+
18591908
# Open the log file for writing.
18601909
open(my $reportFd, ">", $reportFile) ||
18611910
die("Run: can't write to $reportFile\n");
18621911
open(my $reportFd2, ">", $reportHtml) ||
18631912
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+
18641919
printf $reportFd " BYTE UNIX Benchmarks (Version %s)\n\n", $version;
18651920
runHeaderHtml($systemInfo, $reportFd2);
18661921

@@ -1879,13 +1934,24 @@ sub main {
18791934

18801935
summarizeRun($systemInfo, $results, $verbose, $reportFd);
18811936
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+
}
18821945
}
18831946

18841947
runFooterHtml($reportFd2);
18851948

18861949
# Finish the report.
18871950
close($reportFd);
18881951
close($reportFd2);
1952+
if ($isOutputFormatCsv) {
1953+
close($reportFd_Csv);
1954+
}
18891955

18901956
# Display the report, if not in quiet mode.
18911957
if ($verbose > 0) {

UnixBench/USAGE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ so that randomly-churning background processes don't randomise the results
6565
too much. This is particularly true for the graphics tests.
6666

6767

68+
If you need to change the directories, use "Environment variables" about below.
69+
* "UB_OUTPUT_CSV" : If set "true", output results(score only) to .csv.
6870
============================================================================
6971

7072
Tests

0 commit comments

Comments
 (0)