[Swift-commit] r7578 - SwiftApps/heap-plot

davidk at ci.uchicago.edu davidk at ci.uchicago.edu
Fri Feb 7 09:49:50 CST 2014


Author: davidk
Date: 2014-02-07 09:49:49 -0600 (Fri, 07 Feb 2014)
New Revision: 7578

Modified:
   SwiftApps/heap-plot/heap-plot.pl
Log:
Multiplots showing submitted/selecting/active, and a cumulative completed


Modified: SwiftApps/heap-plot/heap-plot.pl
===================================================================
--- SwiftApps/heap-plot/heap-plot.pl	2014-02-07 04:28:40 UTC (rev 7577)
+++ SwiftApps/heap-plot/heap-plot.pl	2014-02-07 15:49:49 UTC (rev 7578)
@@ -8,26 +8,16 @@
    exit 1;
 }
 
-my $first_timestamp=0;
-
-# Read file
-my $filename=shift;
-open(FILE, "$filename") || die "Unable to open $filename\n";
-my @filedata = <FILE>;
-close(FILE);
-
-# Open file for writing
-open(FILE, ">heap-plot.dat") || die "Unable to open activityplot.dat for writing\n";
-print FILE "Time Max Crt Used\n";
-
+# Given "Active: 10", or "HeapMax: 9361686528,", return only values
 sub get_value
 {
    my $statement = $_[0];
    my $value = (split /:/, $statement)[1];
-   chop($value);
+   $value =~ s/,//g;
    return $value;
 }
 
+# Convert Swift time stamp to seconds
 sub timestamp_to_seconds
 {
    (my $date, my $hhmmss, my @junk) = split('\s+', $_[0]);
@@ -37,44 +27,78 @@
    my $time = timelocal_nocheck($ss, $mm, $hh, $monthday-1, $month, $year);
    return $time;
 }
+my $first_timestamp=0;
 
+# Read log
+my $filename=shift;
+open(LOG, "$filename") || die "Unable to open $filename\n";
+my @filedata = <LOG>;
+close(LOG);
+
+# Open data files used for plotting
+open(DAT, ">heap-plot.dat") || die "Unable to create heap-plot.dat\n";
+print DAT "Time Max Crt Used\n";
+open(DAT2, ">heap-plot2.dat") || die "Unable to create heap-plot2.dat\n";
+print DAT2 "Time Active Selecting Submitted\n";
+open(DAT3, ">heap-plot3.dat") || die "Unable to create heap-plot3.dat\n";
+print DAT3 "Time Completed\n";
+
 foreach my $line(@filedata) {
-   if( $line =~ m/HeapMax/ ) {
-      $line =~ s/HeapMax: /HeapMax:/g;
-      $line =~ s/CrtHeap: /CrtHeap:/g;
-      $line =~ s/UsedHeap: /UsedHeap:/g;
-      my @words = split('\s+', $line);
-      my $timestamp = timestamp_to_seconds($line);
 
-      if($first_timestamp == 0) { $first_timestamp = $timestamp; $timestamp=0; } 
-      else { $timestamp = $timestamp - $first_timestamp; }
+   if( $line =~ m/RuntimeStats\$ProgressTicker/ ) {
 
-      my $max = 0;
-      my $crt = 0;
-      my $used = 0;
-      my $active = 0;
+      # Heap line
+      if( $line =~ m/HeapMax/ ) {
+         $line =~ s/HeapMax: /HeapMax:/g;
+         $line =~ s/CrtHeap: /CrtHeap:/g;
+         $line =~ s/UsedHeap: /UsedHeap:/g;
+         my @words = split('\s+', $line);
+         my $timestamp = timestamp_to_seconds($line);
+         if($first_timestamp == 0) { $first_timestamp = $timestamp; $timestamp=0; } 
+         else { $timestamp = $timestamp - $first_timestamp; }
+         my ($max, $crt, $used) = (0) x 3;
+         foreach my $word(@words) {
+            if($word =~ /HeapMax:/)          { $max  = get_value($word); }
+            elsif($word =~ /CrtHeap:/)       { $crt  = get_value($word); }
+            elsif($word =~ /UsedHeap:/)      { $used = get_value($word); }
+         }  
+         print DAT "$timestamp $max $crt $used\n";
+      }
 
-      foreach my $word(@words) {
-         if($word =~ /HeapMax:/)          { $max = get_value($word);    }
-         elsif($word =~ /CrtHeap:/)       { $crt = get_value($word);    }
-         elsif($word =~ /UsedHeap:/)      { $used = get_value($word);   }
-         # elsif($word =~ /Active:/)        { $active = get_value($word); }
-      }  
-
-      # Adjust values for plotting
-      print FILE "$timestamp $max $crt $used\n";
+      # Ticker line
+      else {
+         $line =~ s/Selecting site:/SelectingSite:/g;
+         my @words = split('\s+', $line);
+         my $timestamp = timestamp_to_seconds($line);
+         if($first_timestamp == 0) { $first_timestamp = $timestamp; $timestamp=0; } 
+         else { $timestamp = $timestamp - $first_timestamp; }   
+         my ($active, $submitted, $selecting, $completed) = (0) x 4;
+         foreach my $word(@words) {
+            if($word =~ /Active:/)           { $active    = get_value($word); }
+            elsif($word =~ /Submitted:/)     { $submitted = get_value($word); }
+            elsif($word =~ /SelectingSite:/) { $selecting = get_value($word); } 
+            elsif($word =~ /successfully:/)  { $completed = get_value($word); }
+         }
+         print DAT2 "$timestamp $active $submitted $selecting\n";
+         if($completed != 0) {
+            print DAT3 "$timestamp $completed\n";
+         }
+      }
    }
 }
 
-close(FILE);
-open(FILE, ">heap-plot.gp") || die "Unable to create heap-plot.gp";
+close(DAT);
+close(DAT2);
+close(DAT3);
+open(GP, ">heap-plot.gp") || die "Unable to create heap-plot.gp";
 
 my $gp = <<END;
 set key autotitle columnhead
 set terminal png size 1000,1000 enhanced
-set title "Heap Plot"
 set output "heap-plot.png"
 
+set multiplot layout 3,1 title "Heap Plot"
+
 set xlabel "Time in sec"
 set ylabel "Size in MB"
 set autoscale x
@@ -82,11 +106,22 @@
 plot "heap-plot.dat" using 1:(\$2/1048576) with lines, \\
                   '' using 1:(\$3/1048576) with lines, \\
                   '' using 1:(\$4/1048576) with lines
+
+set xlabel "Time in sec"
+set ylabel "Number of tasks"
+plot "heap-plot2.dat" using 1:(\$2) with lines, \\
+                   '' using 1:(\$3) with lines, \\
+                   '' using 1:(\$4) with lines
+
+set ylabel "Completed"
+plot "heap-plot3.dat" using 1:(\$2) with lines
+
 END
 
-print FILE $gp; 
-close(FILE);
+print GP $gp; 
+close(GP);
 
 system("gnuplot heap-plot.gp");
 unlink("heap-plot.gp");
 unlink("heap-plot.dat");
+unlink("heap-plot2.dat");




More information about the Swift-commit mailing list