report.pl 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. @Reports=@ARGV;
  28. die "usage: $0 <iozone.out> [<iozone2.out>...]\n" if not @Reports or grep (m|^-|, @Reports);
  29. die "report files must be in current directory" if grep (m|/|, @Reports);
  30. %columns=(
  31. 'write' =>3,
  32. 'read' =>5,
  33. 'rewrite' =>4,
  34. 'reread' =>6,
  35. 'randread' =>7,
  36. 'randwrite' =>8,
  37. 'bkwdread' =>9,
  38. 'recrewrite'=>10,
  39. 'strideread'=>11,
  40. 'fwrite' =>12,
  41. 'frewrite' =>13,
  42. 'fread' =>14,
  43. 'freread' =>15,
  44. );
  45. #
  46. # create output directory. the name is the concatenation
  47. # of all report file names (minus the file extension, plus
  48. # prefix report_)
  49. #
  50. $outdir="report_".join("_",map{/([^\.]+)(\..*)?/ && $1}(@Reports));
  51. print STDERR "Output directory: $outdir ";
  52. if ( -d $outdir )
  53. {
  54. print STDERR "(removing old directory) ";
  55. system "rm -rf $outdir";
  56. }
  57. mkdir $outdir or die "cannot make directory $outdir";
  58. print STDERR "done.\nPreparing data files...";
  59. foreach $report (@Reports)
  60. {
  61. open(I, $report) or die "cannot open $report for reading";
  62. $report=~/^([^\.]+)/;
  63. $datafile="$1.dat";
  64. push @datafiles, $datafile;
  65. open(O, ">$outdir/$datafile") or die "cannot open $outdir/$datafile for writing";
  66. open(O2, ">$outdir/2d-$datafile") or die "cannot open $outdir/$datafile for writing";
  67. while(<I>)
  68. {
  69. next unless ( /^[\s\d]+$/ );
  70. @split = split();
  71. next unless ( @split >= 8 );
  72. print O;
  73. print O2 if $split[1] == 16384 or $split[0] == $split[1];
  74. }
  75. close I, O, O2;
  76. }
  77. print STDERR "done.\nGenerating graphs:";
  78. foreach $column (keys %columns)
  79. {
  80. print STDERR " $column";
  81. open(G, ">$outdir/$column.do") or die "cannot open $outdir/$column.do for writing";
  82. print G qq{
  83. set title "Iozone performance: $column"
  84. set grid lt 2 lw 1
  85. set surface
  86. set parametric
  87. set xtics
  88. set ytics
  89. set logscale x 2
  90. set logscale y 2
  91. set autoscale z
  92. #set xrange [2.**5:2.**24]
  93. set xlabel "File size in Kbytes"
  94. set ylabel "Record size in Kbytes"
  95. set zlabel "Kbytes/sec"
  96. set style data lines
  97. set dgrid3d 80,80,3
  98. #set terminal png small picsize 900 700
  99. set terminal png small size 900 700
  100. set output "$column.png"
  101. };
  102. print G "splot ". join(", ", map{qq{"$_" using 1:2:$columns{$column} title "$_"}}(@datafiles));
  103. print G "\n";
  104. close G;
  105. open(G, ">$outdir/2d-$column.do") or die "cannot open $outdir/$column.do for writing";
  106. print G qq{
  107. set title "Iozone performance: $column"
  108. #set terminal png small picsize 450 350
  109. set terminal png small size 450 350
  110. set logscale x
  111. set xlabel "File size in Kbytes"
  112. set ylabel "Kbytes/sec"
  113. set output "2d-$column.png"
  114. };
  115. print G "plot ". join(", ", map{qq{"2d-$_" using 1:$columns{$column} title "$_" with lines}}(@datafiles));
  116. print G "\n";
  117. close G;
  118. if ( system("cd $outdir && gnuplot $column.do && gnuplot 2d-$column.do") )
  119. {
  120. print STDERR "(failed) ";
  121. }
  122. else
  123. {
  124. print STDERR "(ok) ";
  125. }
  126. }
  127. print STDERR "done.\n";