diff --git a/src/plugins/e-acsl/benchmarking/examples/plotting/dat/barplot.dat b/src/plugins/e-acsl/benchmarking/examples/plotting/dat/barplot.dat new file mode 100644 index 0000000000000000000000000000000000000000..725d4337c6b42ce4b561875ef24fc4ba47802600 --- /dev/null +++ b/src/plugins/e-acsl/benchmarking/examples/plotting/dat/barplot.dat @@ -0,0 +1,4 @@ +Benchmark No-model Segment-model Bittree-model +grep 2 4.4 18 +sed 3 9 16 +diff 4 9.3 7.3 diff --git a/src/plugins/e-acsl/benchmarking/examples/plotting/dat/lineplot.dat b/src/plugins/e-acsl/benchmarking/examples/plotting/dat/lineplot.dat new file mode 100644 index 0000000000000000000000000000000000000000..c8851c9a5beff4d6885904e4ed60fc73ef1e1865 --- /dev/null +++ b/src/plugins/e-acsl/benchmarking/examples/plotting/dat/lineplot.dat @@ -0,0 +1,11 @@ +RUNS No-model Segment-model Bittree-model +1 1.1 4.6 8.6 +2 2.3 9.2 13.8 +3 1.0 9.9 11.2 +4 1.9 4.3 6.9 +5 3.4 6.9 12.5 +6 5.4 20.4 33.4 +7 8.1 21.8 36.7 +8 11.6 23.7 16.2 +9 16.6 40.8 22.7 +10 1.15 7.4 8.1 diff --git a/src/plugins/e-acsl/benchmarking/examples/plotting/sample-plot.sh b/src/plugins/e-acsl/benchmarking/examples/plotting/sample-plot.sh new file mode 100755 index 0000000000000000000000000000000000000000..56f3dd52eb0e386769462deda79ce8b25a849cce --- /dev/null +++ b/src/plugins/e-acsl/benchmarking/examples/plotting/sample-plot.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +# Sample script showing usage of `bm.gnuplot` script + +# Path to gnuplot script +BM_GNUPLOT="../../tools/bm.gnuplot" + +# Build a line plot using lineplot.dat data file +gnuplot \ + -e "BaseFile='dat/lineplot'" \ + -e "Style='lines'" \ + -e "WithOverheads=1" \ + -e "PlotTitle='Sample line plot title'" \ + -e "XLabel='Sample line plot label of X axis'" \ + -e "YLabel='Sample line plot label of Y axis'" \ + -e "OutputDir='.'" \ + -e "WithOverheads='1'" \ + $BM_GNUPLOT + +# Build a histogram using barplot.dat data file +gnuplot \ + -e "BaseFile='dat/barplot'" \ + -e "Style='histogram'" \ + -e "WithOverheads=1" \ + -e "PlotTitle='Sample histogram title'" \ + -e "XLabel='Sample histogram label of X axis'" \ + -e "YLabel='Sample histogram label of Y axis'" \ + -e "OutputDir='.'" \ + -e "WithOverheads='1'" \ + $BM_GNUPLOT + +exit 0 diff --git a/src/plugins/e-acsl/benchmarking/tools/line.plot b/src/plugins/e-acsl/benchmarking/tools/bm.gnuplot similarity index 54% rename from src/plugins/e-acsl/benchmarking/tools/line.plot rename to src/plugins/e-acsl/benchmarking/tools/bm.gnuplot index 58507739431d443371b8ebb7de1071d881796a05..59fce6cb7f7bbf8a87018cd4358c994ca07d2080 100755 --- a/src/plugins/e-acsl/benchmarking/tools/line.plot +++ b/src/plugins/e-acsl/benchmarking/tools/bm.gnuplot @@ -22,33 +22,57 @@ # # ########################################################################## -print "========================================================================" -print " Gnuplot script for building line graphs using a data file of the form:" -print " X Y1 Y2 ... YN" -print " 100 2 3 4" -print " ...." -print "" -print " where X, Y1 ... YN are labels and" -print " values of column X are used for x-axis" -print " values of columns Y1 ... YN are used for y-axis" -print "" -print " The script should be invoked as follows:" -print " gnuplot \\" -print " -e \"BaseFile='<Compulsory: Base name of a .dat file>'\" \\" -print " -e \"PlotTitle='<Optional: Plot title: [BaseFile] >'\" \\" -print " -e \"XLabel='<Optional: X-axis label: [\"\"]>'\" \\" -print " -e \"YLabel='<Optional: Y-axis label: [\"1st column title\"]>'\" \\" -print " -e \"WithOverheads='<ANY>'\" \\" -print " data.plot" -print "========================================================================" +# Usage information of a script +# +# Gnuplot script for building line graphs and histograps +# +# The script should be invoked as follows: +# gnuplot \ +# -e "BaseFile='<Base name of .dat file>' \ +# -e "Style='<lines|histogram>' \ +# -e "PlotTitle='<Optional: Plot title: [BaseFile]>'" +# -e "XLabel='<Optional: X-axis label: [""]>'" +# -e "YLabel='<Optional: Y-axis label: ["1st column title"]>'" +# -e "OutputDir='<Optional: directory where to place output files>'" +# -e "WithOverheads='<ANY>'" +# data.plot +# +# Arguments: +# - BaseName - base name of a data file with data to plot. This script expects +# BaseName.dat to exist and contain data. E.g., if the provided value is +# 'foo/bar', then foo/bar.dat file should exist +# - Style - a compulsory argument indicating the type of a plot to be constructed. +# Allowed values are 'histogram' or 'lines'. If 'lines' value is given then +# this script builds a line plot expecting the data file be of the form: +# YLabel XLabel1 XLabel2 ... +# YValue XValue1 XValue2 ... +# ... +# If 'histogram' argument is specified a data file is expected to be of the form: +# GroupLabel Label2 Label3 Label4 +# Group1 Value1 Value2 Value3 ... +# Group2 Value1 Value2 Value3 ... +# ... +# - XLabel - optional string used a X-axis label +# - YLabel - optional string used a Y-axis label +# - PlotTitle - optional string used a plot title +# - OutputDir - optional directory for placement of resulting pdf files +# - WithOverheads - if any value is given to this argument then the script +# computes overheads relative to the values in the second column # Check if a given file exists file_exists(file) = system("test -f '".file."' && echo '1' || echo '0'") + 0 +if (exists("Style") && (Style eq "histogram" && Style eq "lines")) { + print "ERROR: Unknown histogram style [histogram|lines]" + print "See inline comments for details" + exit 1 +} + # Check if the base name of the datafile (name - extension .dat) # is given via commandline if (!exists("BaseFile")) { print "ERROR: Variable 'BaseFile' should be set via commandline" + print "See inline comments for details" exit } @@ -58,6 +82,7 @@ DataFile = BaseFile.'.dat' # Check if it exists if (!file_exists(DataFile)) { print "ERROR: ".DataFile." not found." + print "See inline comments for details" exit } @@ -79,15 +104,15 @@ LegendFont = "Arial,12" SideLabelFont = "Arial-Bold,16" # Line colours -set linetype 6 linecolor rgb "#666633" # Dark yellow -set linetype 5 linecolor rgb "#006633" # Green -set linetype 4 linecolor rgb "#000000" # Black -set linetype 3 linecolor rgb "#990099" # Magenta -set linetype 2 linecolor rgb "#000066" # Dark blue -set linetype 1 linecolor rgb "#990000" # Maroon +set linetype 6 linewidth 2 linecolor rgb "#666633" pointtype 6 pointsize 0.7 # Dark yellow +set linetype 5 linewidth 2 linecolor rgb "#006633" pointtype 5 pointsize 0.7 # Green +set linetype 4 linewidth 2 linecolor rgb "#000000" pointtype 4 pointsize 0.7 # Black +set linetype 3 linewidth 2 linecolor rgb "#990099" pointtype 3 pointsize 0.7 # Magenta +set linetype 2 linewidth 2 linecolor rgb "#000066" pointtype 8 pointsize 0.7 # Dark blue +set linetype 1 linewidth 2 linecolor rgb "#990000" pointtype 7 pointsize 0.7 # Maroon # Use the postscript terminal, as a PDF one is not fully featured -set terminal postscript landscape size 10,7 enhanced color font BaseFont linewidth 3 +set terminal postscript landscape size 10,7 enhanced color font BaseFont # Set background colour for the plot area set object 1 rectangle from graph 0, graph 0 to graph 1, graph 1 behind fc rgbcolor Background fs noborder @@ -112,12 +137,18 @@ set ylabel YLabel font SideLabelFont # Enable macros set macros -OutFile = BaseFile.'.ps' +PsFile = BaseFile.'.ps' PdfFile = BaseFile.'.pdf' + +if (exists("OutputDir")) { + PsFile = OutputDir."/".system("basename ".DataFile) + PdfFile = OutputDir."/".system("basename ".PdfFile) +} + Columns=`tail -n 1 @DataFile | wc -w` # Set output file command -set output OutFile +set output PsFile # Overhead plotting function # nat - time of an original executable @@ -125,10 +156,25 @@ set output OutFile # If WithOverheads var is defined then compute overheads, otherwise plot as is ovh(nat, mod) = exists("WithOverheads") ? mod/nat : mod -# Plotting command -plot for [COL = 2:Columns] DataFile \ - using 1:(ovh(column(2), column(COL))) title columnheader(COL) with lines +################### +# Plotting +################### +# Build a line plot +if (Style eq "lines") { + plot for [COL = 2:Columns] DataFile \ + using 1:(ovh(column(2), column(COL))) title columnheader(COL) with linespoints +} + +# Build a histogram +if (Style eq "histogram") { + set yrange [0:] + set style data histogram + set style fill solid border -1 + plot for [COL=2:Columns] DataFile using (ovh(column(2), column(COL))):xticlabels(1) title columnheader +} # At this point postscript is generated, create PDF -!ps2pdf @OutFile @PdfFile -!rm @OutFile +!ps2pdf @PsFile @PdfFile +!rm @PsFile + +