Index: gs2-extensions/parallel-building/trunk/src/bin/script/generate_gantt.pl
===================================================================
--- gs2-extensions/parallel-building/trunk/src/bin/script/generate_gantt.pl	(revision 28358)
+++ gs2-extensions/parallel-building/trunk/src/bin/script/generate_gantt.pl	(revision 29663)
@@ -14,5 +14,13 @@
 # - configurables
 my $chart_width = 1600;
+# - any video more than 95% complete is probably complete with rounding errors
+my $complete_threshold = 95;
+
 my $debug = 0;
+my $color_master = 'blue';
+my $color_worker = 'green';
+my $color_nlocal = 'red';
+my $disable_header = 0;
+my $max_worker_count = 0;
 # - globals
 my $chart_count = 0;
@@ -40,4 +48,27 @@
     $chart_width = $value;
   }
+  elsif ($option eq '-grayscale')
+  {
+    $color_master = '#1D1D1D';
+    $color_worker = '#969696';
+    $color_nlocal = '#4C4C4C';
+  }
+  elsif ($option eq '-noheader')
+  {
+    $disable_header = 1;
+  }
+  elsif ($option eq '-maxworkers')
+  {
+    if (!defined $ARGV[0])
+    {
+      &printUsage('Error! No maxworkers value specified');
+    }
+    my $value = shift(@ARGV);
+    if ($value !~ /^\d+$/)
+    {
+      &printUsage('Error! Maxworkers not a number');
+    }
+    $max_worker_count = $value;
+  }
   else
   {
@@ -46,4 +77,5 @@
 }
 print "Chart Width: " . $chart_width . "px\n";
+print "Grayscale? " . ($debug ? 'Yes' : 'No') . "\n";
 print "Debug? " . ($debug ? 'Yes' : 'No') . "\n";
 print "===================================\n\n";
@@ -149,6 +181,14 @@
         my $filepath = $parts[8];
         $filepath =~ s/^\s+|\s+$//g;
-        my $percent_complete = $parts[9];
-        chomp($percent_complete);
+        my $percent_complete = 'NA';
+        if (defined($parts[9]))
+        {
+          $percent_complete = $parts[9];
+          chomp($percent_complete);
+          if ($percent_complete >= $complete_threshold)
+          {
+            $percent_complete = 'NA';
+          }
+        }
         $import_dir = &longestCommonPath($filepath, $import_dir);
         my $start_time = $parts[3];
@@ -175,17 +215,25 @@
   print HTMLOUT '<head>' . "\n";
   print HTMLOUT '<style type="text/css">' . "\n";
+  print HTMLOUT "body {margin:0px;padding:4px}\n";
   print HTMLOUT 'div.thread {position:relative}' . "\n";
   print HTMLOUT 'div.master {border:1px solid gray;color:white;font-weight:bold}' . "\n";
-  print HTMLOUT 'div.worker {border:1px solid black;background-color:green;color:white;font-weight:bold;margin-bottom:1px;}' . "\n";
+  print HTMLOUT 'div.worker {border:1px solid black;background-color:' . $color_worker . ';color:white;font-weight:bold;margin-bottom:1px;}' . "\n";
   print HTMLOUT 'div.time {font-size:smaller;font-weight:normal}' . "\n";
-  print HTMLOUT 'div.job {background-color:transparent;color:black;border:1px solid black;display:block;font-size:smaller;position:relative;text-align:center;overflow:hidden;margin-bottom:1px;}' . "\n";
+  print HTMLOUT 'div.job {background-color:transparent;color:black;border:1px solid black;display:block;font-size:smaller;font-weight:normal;position:relative;text-align:left;margin-bottom:1px;}' . "\n";
   print HTMLOUT 'span.process {z-index:-1;background-color:#C7C7C7;position:absolute}' . "\n";
-  print HTMLOUT 'span.label {z-index:1;background-color:transparent;overflow:hidden;white-space:nowrap;}' . "\n";
+  print HTMLOUT 'div.label {z-index:1;background-color:transparent;white-space:nowrap;text-align:center}' . "\n";
   print HTMLOUT "th {text-align:left}\n";
+  print HTMLOUT "tr.toprule th,tr.toprule td {border-top:2px solid black;width:17%}\n";
+  print HTMLOUT "tr.bottomrule th,tr.bottomrule td {border-bottom:2px solid black}\n";
   print HTMLOUT '</style>' . "\n";
   print HTMLOUT '</head>' . "\n";
   print HTMLOUT "<body>\n";
-  print HTMLOUT "<h2>Statistics</h2>\n";
-  print HTMLOUT "<table style=\"width:100%;\">\n";
+  ##print HTMLOUT "<h2>Parallel Import Timing Chart</h2>\n";
+  print HTMLOUT "<table style=\"border-collapse:collapse;width:" . $chart_width . "px;";
+  if ($disable_header)
+  {
+    print HTMLOUT "display:none;";
+  }
+  print HTMLOUT "\">\n";
 
   my $total_duration = $timing_data->{'M'}->{'E'} - $timing_data->{'M'}->{'S'};
@@ -206,5 +254,6 @@
         my $process_end = $timing_data->{$worker_id}->{'F'}->{$job_start}->{'PE'};
         my $job_end = $timing_data->{$worker_id}->{'F'}->{$job_start}->{'E'};
-        if ($process_start == 0 || $process_end == 0 || $job_end == 0)
+        my $percent_complete = $timing_data->{$worker_id}->{'F'}->{$job_start}->{'PC'};
+        if ($process_start == 0 || $process_end == 0 || $job_end == 0 || ($percent_complete =~ /^\d+$/ && $percent_complete < $complete_threshold))
         {
           $problem_files++;
@@ -255,13 +304,13 @@
   my $avg_cpu_time = int(($total_process_time / $file_count) + 0.5);
 
-  print HTMLOUT "<tr>\n";
-  print HTMLOUT ' <th style="width:12%;">Import Directory:</th><td style="width:22%;" colspan="5">' . $import_dir . "</td>\n";
+  print HTMLOUT "<tr class=\"toprule\">\n";
+  print HTMLOUT ' <th style="width:17%;">Import Directory:</th><td style="width:83%;" colspan="5">' . $import_dir . "</td>\n";
   print HTMLOUT "</tr>\n";
 
   print HTMLOUT "<tr>\n";
   my ($sec, $min, $hour, $day, $month, $year) = (localtime($timing_data->{'M'}->{'S'}))[0,1,2,3,4,5];
-  print HTMLOUT ' <th style="width:11%;">Start Time:</th><td style="width:22%;">' . sprintf('%04d%s%02d %02d:%02d:%02d', ($year+1900), $months[$month], $day, $hour, $min, $sec) . "</td>\n";
+  print HTMLOUT ' <th>Start Time:</th><td>' . sprintf('%04d%s%02d %02d:%02d:%02d', ($year+1900), $months[$month], $day, $hour, $min, $sec) . "</td>\n";
   ($sec, $min, $hour, $day, $month, $year) = (localtime($timing_data->{'M'}->{'E'}))[0,1,2,3,4,5];
-  print HTMLOUT ' <th style="width:11%;">End Time:</th><td style="width:22%;">' . sprintf('%04d%s%02d %02d:%02d:%02d', ($year+1900), $months[$month], $day, $hour, $min, $sec) . "</td>\n";
+  print HTMLOUT ' <th>End Time:</th><td>' . sprintf('%04d%s%02d %02d:%02d:%02d', ($year+1900), $months[$month], $day, $hour, $min, $sec) . "</td>\n";
   print HTMLOUT "  <th>Processing Time:</th><td>" . &renderTime($total_duration) . "</td>\n";
   print HTMLOUT "</tr>\n";
@@ -280,10 +329,10 @@
 
   print HTMLOUT "<tr>\n";
-  print HTMLOUT "  <th>Average Processing Time:</th><td>" . &renderTime($avg_processing_time) . "</td>\n";
-  print HTMLOUT "  <th>Average File IO Time:</th><td>" . &renderTime($avg_io_time) . "</td>\n";
-  print HTMLOUT "  <th>Average File CPU Time:</th><td>" . &renderTime($avg_cpu_time) . "</td>\n";
+  print HTMLOUT "  <th>Avg Processing Time:</th><td>" . &renderTime($avg_processing_time) . "</td>\n";
+  print HTMLOUT "  <th>Avg File IO Time:</th><td>" . &renderTime($avg_io_time) . "</td>\n";
+  print HTMLOUT "  <th>Avg File CPU Time:</th><td>" . &renderTime($avg_cpu_time) . "</td>\n";
   print HTMLOUT "</tr>\n";
 
-  print HTMLOUT "<tr>\n";
+  print HTMLOUT "<tr class=\"bottomrule\">\n";
   print HTMLOUT "  <th>Fastest File:</th><td>" . &renderTime($fastest_file) . "</td>\n";
   print HTMLOUT "  <th>Slowest File:</th><td>" . &renderTime($slowest_file) . "</td>\n";
@@ -299,16 +348,19 @@
 
   print HTMLOUT "</table>\n";
-  print HTMLOUT "<hr />\n";
-  print HTMLOUT "<h2>Timing Chart (Gantt)</h2>\n";
   print HTMLOUT renderLine($chart_width, $timing_data->{'M'}->{'S'}, $timing_data->{'M'}->{'E'}, 'master', $timing_data->{'M'}->{'N'}, $timing_data->{'M'}->{'S'}, $timing_data->{'M'}->{'E'}, {}, $data_locality);
+  my $worker_count = 0;
   foreach my $worker_id (nsort keys %{$timing_data})
   {
-    if ($worker_id ne 'M')
-    {
-      my $data = $timing_data->{$worker_id};
-      print HTMLOUT renderLine($chart_width, $timing_data->{'M'}->{'S'}, $timing_data->{'M'}->{'E'}, 'worker', $worker_id . ' [' . $data->{'N'} . ']', $data->{'S'}, $data->{'E'}, $data->{'F'}, 2); #$data_locality);
-    }
-  }
-  print HTMLOUT '<div>' . "\n";
+    if ($max_worker_count < 1 || $worker_count <= $max_worker_count)
+    {
+      if ($worker_id ne 'M')
+      {
+        my $data = $timing_data->{$worker_id};
+        print HTMLOUT renderLine($chart_width, $timing_data->{'M'}->{'S'}, $timing_data->{'M'}->{'E'}, 'worker', $worker_id . ' [' . $data->{'N'} . ']', $data->{'S'}, $data->{'E'}, $data->{'F'}, 2); #$data_locality);
+        $worker_count++;
+      }
+    }
+  }
+  print HTMLOUT '</div>' . "\n";
   print HTMLOUT "</body>\n";
   print HTMLOUT "</html>";
@@ -441,5 +493,5 @@
   if ($class eq 'master')
   {
-    $html .= '<div style="background-color:blue;margin-bottom:1px">';
+    $html .= '<div style="background-color:' . $color_master . ';margin-bottom:1px">';
   }
   $html .= '<div class="time" style="display:table-cell">' . &renderTime($rtstart) . '</div><div style="display:table-cell;padding-left:20px;width:100%;">' . ucfirst($class) . ': ' . $tname . '</div><div class="time" style="display:table-cell">' . renderTime($rtend) . '</div></div>';
@@ -470,18 +522,18 @@
     my $cpu_percent = int((($rpwidth / $jwidth) * 100) + 0.5);
     $html .= '<div class="job" style="left:' . $jleft . 'px;width:' . $jwidth . 'px;';
-    print "Data Locality? " . $data_locality . " DL? " . $jobs->{$jstart}->{'DL'} . "\n";
+    ###rint "Data Locality? " . $data_locality . " DL? " . $jobs->{$jstart}->{'DL'} . "\n";
     if ($data_locality > 1 && $jobs->{$jstart}->{'DL'} != 1)
     {
-      $html .= 'border:1px dashed black;';
-    }
-    $html .= '" title="FN:' . $jobs->{$jstart}->{'FN'} . ', S:' . &renderTime($rjstart) . ', E:' . &renderTime($rjend) . ', CPU: ' . $cpu_percent . '% [' . &renderTime($io_duration) . ', ' . &renderTime($cpu_duration) . ', PC: ' . $jobs->{$jstart}->{'PC'} . '%]"><span class="process" style="left:' . $rpleft . 'px;width:' . $rpwidth . 'px">&nbsp;</span><span class="label"';
+      $html .= 'border:1px solid #C7C7C7;';
+    }
+    $html .= '" title="FN:' . $jobs->{$jstart}->{'FN'} . ', S:' . &renderTime($rjstart) . ', E:' . &renderTime($rjend) . ', CPU: ' . $cpu_percent . '% [' . &renderTime($io_duration) . ', ' . &renderTime($cpu_duration) . ', PC: ' . $jobs->{$jstart}->{'PC'} . '%]"><span class="process" style="left:' . $rpleft . 'px;width:' . $rpwidth . 'px">&nbsp;</span><div class="label" style="width:' . $jwidth;
     if ($data_locality > 1 && $jobs->{$jstart}->{'DL'} != 1)
     {
-      $html .= ' style="color:#FF0000"';
-    }
-    $html .=  '>' . $jobs->{$jstart}->{'FN'};
+      $html .= ';color:' . $color_nlocal;
+    }
+    $html .=  '">' . $jobs->{$jstart}->{'FN'};
     if ($jobs->{$jstart}->{'PC'} ne 'NA')
     {
-      $html .= ' <small>[' . $jobs->{$jstart}->{'PC'} . '%]</small>';
+      $html .= ' <b>[Incomplete! ' . $jobs->{$jstart}->{'PC'} . '%]</b>';
     }
     if ($data_locality > 1 && $jobs->{$jstart}->{'DL'} != 1)
@@ -489,5 +541,5 @@
       $html .= ' [NL]';
     }
-    $html .= '</span></div>';
+    $html .= '</div></div>';
   }
   return $html;
