From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dario Faggioli Subject: [PATCH 09/27] ts-unixbench-reslts: process and plot bench results Date: Wed, 10 Dec 2014 19:10:06 +0100 Message-ID: <20141210181006.26400.25863.stgit@Abyss.station> References: <20141210180651.26400.13356.stgit@Abyss.station> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20141210180651.26400.13356.stgit@Abyss.station> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: Ian Jackson , Wei Liu , Ian Campbell List-Id: xen-devel@lists.xenproject.org From: Dario Faggioli Mangle the results of a run of unixbench a bit, so that they can be plotted. This also produces a (gnu)plot script and the plot itself. All is saved in $stash, for the running flight and job. This is done in a new Osstest/Benchmarking.pm module, as the functions introduced may turn out useful somewhere else too. The results are read from the original unixbench results file and a new file, with basically a table in it is produced. Gnuplot uses such file as data for the plotting. A gnuplot script is produced and invoked (and saved in $stash) rather than using the gnuplot perl binding because, this way, one can modify the plotting commands a bit, and regen the plot(s). Signed-off-by: Dario Faggioli Cc: Wei Liu Cc: Ian Campbell Cc: Ian Jackson --- Osstest/Benchmarking.pm | 115 +++++++++++++++++++++++++++++++++++++++++++++++ ts-unixbench-reslts | 17 +++++++ 2 files changed, 132 insertions(+) create mode 100644 Osstest/Benchmarking.pm diff --git a/Osstest/Benchmarking.pm b/Osstest/Benchmarking.pm new file mode 100644 index 0000000..0c5c538 --- /dev/null +++ b/Osstest/Benchmarking.pm @@ -0,0 +1,115 @@ +# This is part of "osstest", an automated testing framework for Xen. +# Copyright (C) 2009-2013 Citrix Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +package Osstest::Benchmarking; + +use strict; +use warnings; + +use IO::File; +use IPC::Cmd qw[can_run run]; + +use Osstest; +use Osstest::TestSupport; + +BEGIN { + use Exporter (); + our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); + $VERSION = 1.00; + @ISA = qw(Exporter); + @EXPORT = qw(unixbench_process_results + unixbench_print_results + unixbench_plot_results + ); + %EXPORT_TAGS = ( ); + + @EXPORT_OK = qw(); +} + +#---------- manipulation of benchmarks results ---------- + +sub unixbench_process_results ($$) { + my ($results_ref,$rfilen)= @_; + my $h= new IO::File "< $rfilen" or die "$!"; + + my $par; + while (<$h>) { + my ($bench,$val,$idx); + if (m/.*running ([0-9]*) parallel.*$/) { + $par= $1; + } + if (m/^(\S[a-zA-z0-9-\(\)\s]*)\s([0-9]+.[0-9]?)\s*([0-9]+.[0-9]?)\s*([0-9]+.[0-9]?)$/) { + $val= $3; + $idx= $4; + ($bench = $1) =~ s/\s+$//; + $$results_ref->{"$bench"}{Result}{"$par"}= $val; + $$results_ref->{"$bench"}{Index}{"$par"}= $idx; + } + next; + } + close($h); +} + +sub unixbench_print_results ($$) { + my ($results,$rfilen)= @_; + open my $h, "|-", "tee $rfilen" or die "$!"; + + printf $h "%-50s","\"BENCHMARK NAME\""; + foreach my $i (sort keys $results->{'Double-Precision Whetstone'}{Index}) { + printf $h "%-15s","\"$i VCPUs\""; + } + print $h "\n"; + foreach my $b (keys $results) { + printf $h "%-50s","\"$b\""; + foreach my $i (sort keys $results->{"$b"}{Index}) { + printf $h "%-15s",$results->{$b}{Index}{$i}; + } + print $h "\n"; + } + close($h); +} + +sub unixbench_plot_results ($$$) { + my ($dataf,$num_cols,$pfile)= @_; + my $h= new IO::File "> $pfile.gp" or die "$!"; + + printf $h < "$gp $pfile.gp", verbose => 1 ); + logm("WARNING: plotting file with \"$err\"") unless $ok; +} + +1; diff --git a/ts-unixbench-reslts b/ts-unixbench-reslts index 6e5a9a8..b480d15 100755 --- a/ts-unixbench-reslts +++ b/ts-unixbench-reslts @@ -21,6 +21,7 @@ use DBI; use IO::File; use POSIX; use Osstest::TestSupport; +use Osstest::Benchmarking; tsreadconfig(); @@ -46,6 +47,8 @@ $lresfile .= (defined($r{'unixbench_run_suffix'})) ? $r{'unixbench_run_suffix'} : ''; $lresfile = "unixbench$lresfile"; +our $results; + # Unixbench stores results in a subdirectory called 'results'. The file name # is made up out of the box's hostname, today's date and a progressive id # (e.g., results/benny-2014-07-02-01). @@ -64,4 +67,18 @@ END "$lresfile"); } +sub process () { + my $resf= "$stash/$gho->{Name}--$lresfile"; + my $dataf= "$resf-DATA"; + my $plotf= "$resf-PLOT"; + + unixbench_process_results(\$results,$resf); + unixbench_print_results($results,$dataf); + + # For plotting we need to know the number of data columns + my $ncols= keys $results->{'Double-Precision Whetstone'}{Index}; + unixbench_plot_results($dataf,$ncols,$plotf); +} + fetch(); +process();