| 1 | #!/usr/bin/perl
|
|---|
| 2 | use Path::Class;
|
|---|
| 3 | use File::Basename;
|
|---|
| 4 | use autodie;
|
|---|
| 5 | use strict;
|
|---|
| 6 | use warnings;
|
|---|
| 7 | use File::Path qw(make_path);
|
|---|
| 8 |
|
|---|
| 9 | my $civlDir="."; # directory to civl
|
|---|
| 10 | my $numArgs = scalar(@ARGV);
|
|---|
| 11 | my $datOut = ".";
|
|---|
| 12 | my $benchOut = "bench.scale.out";
|
|---|
| 13 | my $hasCivlDir=0;
|
|---|
| 14 | my $datDir;
|
|---|
| 15 | my $lastReleaseDat;
|
|---|
| 16 |
|
|---|
| 17 | for(my $i=0; $i < $numArgs; $i++){
|
|---|
| 18 | my $arg = $ARGV[$i];
|
|---|
| 19 |
|
|---|
| 20 | if($arg =~ /^\-d(.*)$/){
|
|---|
| 21 | $civlDir=$1;
|
|---|
| 22 | $hasCivlDir=1;
|
|---|
| 23 | }elsif ($arg =~ /^\-o(.*)$/){
|
|---|
| 24 | $datOut = $1;
|
|---|
| 25 | #if(!($datOut =~ /\.pdf$/)){
|
|---|
| 26 | #warn "$out is not a pdf file name, $out.pdf will be used for output file instead.\n";
|
|---|
| 27 | # $out="$out.pdf";
|
|---|
| 28 | # }
|
|---|
| 29 | }else{
|
|---|
| 30 | warn "Arguments should start with -d or -o, invalid argument $arg would be ignored.\n";
|
|---|
| 31 | }
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | if($hasCivlDir == 0){
|
|---|
| 35 | warn "no civl directory is provided, current directory will be used as the civl directory.\n";
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | unless (-d $datOut) {
|
|---|
| 39 | mkdir $datOut;
|
|---|
| 40 | }
|
|---|
| 41 | $benchOut="$datOut/$benchOut";
|
|---|
| 42 |
|
|---|
| 43 | my $scriptPrefix="$civlDir/scripts/scale";
|
|---|
| 44 |
|
|---|
| 45 | ## Get last release version number ...
|
|---|
| 46 | my $lastReleaseVersion;
|
|---|
| 47 |
|
|---|
| 48 | opendir(my $scriptDir, "$scriptPrefix");
|
|---|
| 49 | while (readdir $scriptDir) {
|
|---|
| 50 | if ($_ =~ (/^v(([0-9]+).([0-9]+).([0-9]*))_bench_dat$/)) {
|
|---|
| 51 | $lastReleaseVersion = $1;
|
|---|
| 52 | print "Benchmark running results of CIVL v$lastReleaseVersion found\n";
|
|---|
| 53 | last;
|
|---|
| 54 | }
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | print "running scale benchmarks...\n";
|
|---|
| 58 | my $cmd = `$scriptPrefix/runBenchScale.pl $civlDir -o$benchOut`;
|
|---|
| 59 | print "scale benchmarks finished, now generating .dat file in $datOut...\n";
|
|---|
| 60 | $cmd = `$scriptPrefix/parseScale.pl $benchOut $datOut`;
|
|---|
| 61 | print ".dat file finished, now generating figure...\n";
|
|---|
| 62 |
|
|---|
| 63 | $datDir=dir("$datOut");
|
|---|
| 64 | while(my $datFile = $datDir->next){
|
|---|
| 65 | next unless ($datFile =~ /\.dat$/);
|
|---|
| 66 | my $benchmark;
|
|---|
| 67 |
|
|---|
| 68 | $datFile = basename($datFile, "");
|
|---|
| 69 | ($benchmark) = ($datFile =~ /(.*)\.dat/);
|
|---|
| 70 | if($benchmark eq "Diningphilosopher"){
|
|---|
| 71 | $benchmark="Dining philosopher";
|
|---|
| 72 | }
|
|---|
| 73 | print "plotting figure for benchmark $benchmark...\n";
|
|---|
| 74 | if (defined $lastReleaseVersion) {
|
|---|
| 75 | $cmd = `gnuplot -e "TITLE='$benchmark'" -e "DAT_FILE='$datOut/$datFile'" -e "OUT_FILE='$datOut/$benchmark.pdf'" -e "LAST_DAT_FILE='$scriptPrefix/v$lastReleaseVersion\_bench_dat/$datFile'" -e "LAST_VERSION='v$lastReleaseVersion'" $scriptPrefix/plotBench.plg`;
|
|---|
| 76 | } else {
|
|---|
| 77 | print "No benchmark running results of previous versions found\n";
|
|---|
| 78 | $cmd = `gnuplot -e "TITLE='$benchmark'" -e "DAT_FILE='$datOut/$datFile'" -e "OUT_FILE='$datOut/$benchmark.pdf'" $scriptPrefix/plotBench.plg`;
|
|---|
| 79 | }
|
|---|
| 80 | }
|
|---|
| 81 | print "scaling figures is successfully generated in $datOut\n";
|
|---|
| 82 | #print "copy benchmark results to Ziqing's directory /home/ziqing ...";
|
|---|
| 83 | #$cmd = `cp -a $datDir /home/ziqing/ `;
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|