Changeset 28719 for trunk/tools/czarplot.pl
- Timestamp:
- Jul 27, 2010, 2:42:17 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/tools/czarplot.pl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/czarplot.pl
r28714 r28719 5 5 6 6 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 7 use File::Temp qw(tempfile);8 7 use POSIX qw/strftime/; 9 8 10 9 use czartool::CzarDb; 11 use czartool::Gnuplot; 12 10 use czartool::Czarplot; 13 11 14 12 my $czarDbName = "czardb"; … … 19 17 my $begin = undef; 20 18 my $end = undef; 19 my $path = undef; 21 20 my $verbose = undef; 22 21 my $histogram = undef; 23 22 my $timeSeries = undef; 23 my $savingToFile = undef; 24 24 25 25 GetOptions ( … … 30 30 "begin|b=s" => \$begin, 31 31 "end|e=s" => \$end, 32 "output|o=s" => \$path, 32 33 "histogram|h" => \$histogram, 33 34 "timeseries|t" => \$timeSeries, … … 37 38 print "\n"; 38 39 if (!$histogram) { 39 print "* OPTIONAL: plot histogram -h (default=on)\n"; 40 } 40 print "* OPTIONAL: plot histogram -h (default=off)\n";} 41 41 if (!$timeSeries) { 42 print "* OPTIONAL: plot timeseries -t (default=on)\n"; 43 } 42 print "* OPTIONAL: plot timeseries -t (default=on)\n";} 44 43 if (!$label) { 45 print "* OPTIONAL: choose a label -l <labellName> (default='all_labels')\n"; 46 } 44 print "* OPTIONAL: choose a label -l <labellName> (default='all_labels')\n";} 47 45 if (!$stage) { 48 print "* OPTIONAL: choose a stage -s <chip|cam|warp|etc> (default=none)\n"; 49 } 46 print "* OPTIONAL: choose a stage -s <chip|cam|warp|etc> (default=none)\n";} 50 47 if (!$interval) { 51 print "* OPTIONAL: choose time interval in past -i <'1 hour'|'1 day'|etc> (default=interval since 7am this morning)\n"; 52 } 48 print "* OPTIONAL: choose time interval in past -i <'1 hour'|'1 day'|etc> (default=interval since 7am this morning)\n";} 53 49 if (!$begin) { 54 print "* OPTIONAL: choose a begin time -d <datetime> (default=7am this morning)\n"; 55 } 50 print "* OPTIONAL: choose a begin time -d <datetime> (default=7am this morning)\n";} 56 51 if (!$end) { 57 print "* OPTIONAL: choose an end time -e <datetime> (default=now)\n"; 58 } 52 print "* OPTIONAL: choose an end time -e <datetime> (default=now)\n";} 53 if (!$path) { 54 print "* OPTIONAL: choose an output location -o <path> (default=none)\n";} 59 55 60 56 print "\n"; … … 62 58 # default values 63 59 if (!$label) {$label = "all_labels";} 64 if (!$histogram && !$timeSeries) {$timeSeries = 1; }60 if (!$histogram && !$timeSeries) {$timeSeries = 1; $histogram = 1;} 65 61 if (!$verbose) {$verbose = 0;} 66 62 if (!$save_temps) {$save_temps = 0;} 63 if (!$path) {$savingToFile = 0; $path = ".";} 64 else {$savingToFile = 1;} 67 65 68 66 my $czarDb = new czartool::CzarDb($czarDbName, "ippdb01", "ipp", "ipp", $verbose); 69 my $gnuplot = new czartool::Gnuplot("%Y%m%d-%H%M%S", "X11", "histo.pbm");70 67 $czarDb->setDateFormat("%Y%m%d-%H%i%s"); 68 69 my $czarplot = new czartool::Czarplot($czarDb, "%Y%m%d-%H%M%S", $savingToFile ? "png" : "X11", $path, $save_temps); 71 70 72 71 my @allStages = ("chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist"); … … 79 78 } 80 79 81 if ($ histogram) {plotHistogram($label, $begin, $end);}82 if ($ timeSeries) {plotTimeSeries($label, $stage, $begin, $end);}80 if ($timeSeries) {$czarplot->createTimeSeries($label, $stage, $begin, $end);} 81 if ($histogram) {$czarplot->createHistogram($label, $begin, $end);} 83 82 84 ###########################################################################85 #86 # Plots a time series for all stages for this label87 #88 ###########################################################################89 sub plotTimeSeries {90 my ($label, $selectedStage, $beginTime, $endTime) = @_;91 92 my ($minX, $maxX, $minY, $maxY, $timeDiff);93 $minX = 999999999;94 $maxX = -9999999999;95 $minY = 999999999;96 $maxY = -99999999;97 98 my $stages = undef;99 100 if (!$selectedStage) {$stages = \@allStages;}101 else {$stages = ["$selectedStage"]};102 103 my %gnuplotFiles;104 foreach $stage (@{$stages}) {105 $gnuplotFiles{$stage} = $czarDb->createTimeSeriesData($save_temps, $label, $stage, $beginTime, $endTime, \$minX, \$maxX, \$minY, \$maxY, \$timeDiff);106 }107 108 if (!$selectedStage) {$gnuplot->plotAllStagesTimeSeries($label, $beginTime, $endTime, $maxX, $minX, $maxY, $minY, $timeDiff, \%gnuplotFiles);}109 else {$gnuplot->plotSingleTimeSeries($gnuplotFiles{$selectedStage}, $selectedStage, $label, $beginTime, $endTime, $maxX, $minX, $maxY, $minY, $timeDiff);}110 111 }112 113 ###########################################################################114 #115 # Plots a histogram of stuff processed in provided interval and label for all stages116 #117 ###########################################################################118 sub plotHistogram {119 my ($label, $beginTime, $endTime) = @_;120 121 my ($tempFile, $filePath) = tempfile( "/tmp/czartool_gnuplot_histogram.XXXX", UNLINK => !$save_temps);122 my ($processed, $pending, $faults);123 124 foreach $stage (@allStages) {125 126 $czarDb->countProcessedPendingAndFaults($label, $stage, $beginTime, $endTime, \$processed, \$pending, \$faults);127 print $tempFile "$stage $processed, $pending, $faults\n";128 }129 130 close($tempFile);131 132 $gnuplot->plotHistogram($filePath, $label, $beginTime, $endTime);133 }134 135 136
Note:
See TracChangeset
for help on using the changeset viewer.
