1#!/usr/bin/perl 2# 3# arguments: one of more report files 4# 5# Christian Mautner <christian * mautner . ca>, 2005-10-31 6# 7# This script is based loosely on the Generate_Graph set 8# of scripts that come with iozone, but is a complete re-write 9# 10# The main reason to write this was the need to compare the behaviour of 11# two or more different setups, for tuning filesystems or 12# comparing different pieces of hardware. 13# 14# This script is in the public domain, too short and too trivial 15# to deserve a copyright. 16# 17# Simply run iozone like, for example, ./iozone -a -g 4G > config1.out (if your machine has 4GB) 18# and then run perl report.pl config1.out 19# or get another report from another box into config2.out and run 20# perl report.pl config1.out config2.out 21# the look in the report_* directory for .png 22# 23# If you don't like png or the graphic size, search for "set terminal" in this file and put whatever gnuplot 24# terminal you want. Note I've also noticed that gnuplot switched the set terminal png syntax 25# a while back, you might need "set terminal png small size 900,700" 26# 27 28 29@Reports=@ARGV; 30 31die "usage: $0 <iozone.out> [<iozone2.out>...]\n" if not @Reports or grep (m|^-|, @Reports); 32 33die "report files must be in current directory" if grep (m|/|, @Reports); 34 35%columns=( 36 'write' =>3, 37 'read' =>5, 38 'rewrite' =>4, 39 'reread' =>6, 40 'randread' =>7, 41 'randwrite' =>8, 42 'bkwdread' =>9, 43 'recrewrite'=>10, 44 'strideread'=>11, 45 'fwrite' =>12, 46 'frewrite' =>13, 47 'fread' =>14, 48 'freread' =>15, 49 ); 50 51# 52# create output directory. the name is the concatenation 53# of all report file names (minus the file extension, plus 54# prefix report_) 55# 56$outdir="report_".join("_",map{/([^\.]+)(\..*)?/ && $1}(@Reports)); 57 58print STDERR "Output directory: $outdir "; 59 60if ( -d $outdir ) 61{ 62 print STDERR "(removing old directory) "; 63 system "rm -rf $outdir"; 64} 65 66mkdir $outdir or die "cannot make directory $outdir"; 67 68print STDERR "done.\nPreparing data files..."; 69 70foreach $report (@Reports) 71{ 72 open(I, $report) or die "cannot open $report for reading"; 73 $report=~/^([^\.]+)/; 74 $datafile="$1.dat"; 75 push @datafiles, $datafile; 76 open(O, ">$outdir/$datafile") or die "cannot open $outdir/$datafile for writing"; 77 open(O2, ">$outdir/2d-$datafile") or die "cannot open $outdir/$datafile for writing"; 78 while(<I>) 79 { 80 next unless ( /^[\s\d]+$/ ); 81 @split = split(); 82 next unless ( @split >= 8 ); 83 print O; 84 print O2 if $split[1] == 16384 or $split[0] == $split[1]; 85 } 86 close I, O, O2; 87} 88 89print STDERR "done.\nGenerating graphs:"; 90 91foreach $column (keys %columns) 92{ 93 print STDERR " $column"; 94 95 open(G, ">$outdir/$column.do") or die "cannot open $outdir/$column.do for writing"; 96 print G qq{ 97set title "Iozone performance: $column" 98set grid lt 2 lw 1 99set surface 100set parametric 101set xtics 102set ytics 103set logscale x 2 104set logscale y 2 105set autoscale z 106#set xrange [2.**5:2.**24] 107set xlabel "File size in Kbytes" 108set ylabel "Record size in Kbytes" 109set zlabel "Kbytes/sec" 110set style data lines 111set dgrid3d 80,80,3 112#set terminal png small picsize 900 700 113set terminal png small size 900 700 114set output "$column.png" 115}; 116 117 print G "splot ". join(", ", map{qq{"$_" using 1:2:$columns{$column} title "$_"}}(@datafiles)); 118 119 print G "\n"; 120 121 close G; 122 123 open(G, ">$outdir/2d-$column.do") or die "cannot open $outdir/$column.do for writing"; 124 print G qq{ 125set title "Iozone performance: $column" 126#set terminal png small picsize 450 350 127set terminal png small size 450 350 128set logscale x 129set xlabel "File size in Kbytes" 130set ylabel "Kbytes/sec" 131set output "2d-$column.png" 132}; 133 134 print G "plot ". join(", ", map{qq{"2d-$_" using 1:$columns{$column} title "$_" with lines}}(@datafiles)); 135 136 print G "\n"; 137 138 close G; 139 140 if ( system("cd $outdir && gnuplot $column.do && gnuplot 2d-$column.do") ) 141 { 142 print STDERR "(failed) "; 143 } 144 else 145 { 146 print STDERR "(ok) "; 147 } 148} 149 150print STDERR "done.\n"; 151 152