Changeset 28783
- Timestamp:
- Jul 29, 2010, 2:46:11 PM (16 years ago)
- Location:
- trunk/tools/czartool
- Files:
-
- 2 edited
-
CzarDb.pm (modified) (15 diffs)
-
Czarplot.pm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/czartool/CzarDb.pm
r28770 r28783 5 5 use warnings; 6 6 use strict; 7 8 use File::Temp qw(tempfile);9 7 10 8 my @stages = ("chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist"); # TODO put elsewhere … … 125 123 ########################################################################### 126 124 sub insertNewTimeData { 127 my ($self, $ table, $label, $pending, $processed, $faults, $reverting) = @_;128 129 my $query = $self->{_db}->prepare(<<SQL); 130 INSERT INTO $ table125 my ($self, $stage, $label, $pending, $processed, $faults, $reverting) = @_; 126 127 my $query = $self->{_db}->prepare(<<SQL); 128 INSERT INTO $stage 131 129 (label, pending, processed, faults, reverting) 132 130 VALUES … … 140 138 ########################################################################### 141 139 # 142 # Gets time difference in seconds for these two times140 # Gets time difference in seconds for these two times 143 141 # 144 142 ########################################################################### … … 146 144 my ($self, $fromTime, $toTime) = @_; 147 145 148 my ($tempFile, $tempName) = tempfile( "/tmp/czartool_gnuplot_timeseries.XXXX", UNLINK => !$self->{_save_temps});149 150 146 my $query = $self->{_db}->prepare(<<SQL); 151 147 SELECT … … 164 160 ########################################################################### 165 161 sub createTimeSeriesData { 166 my ($self, $label, $table, $fromTime, $toTime, $minX, $maxX, $minY, $maxY, $timeDiff) = @_; 167 168 my ($tempFile, $tempName) = tempfile( "/tmp/czartool_gnuplot_timeseries.XXXX", UNLINK => !$self->{_save_temps}); 162 my ($self, $label, $stage, $fromTime, $toTime, $minX, $maxX, $minY, $maxY, $timeDiff) = @_; 163 164 my $dataFile = "/tmp/czarplot_gnuplot_".$label."_".$stage."_t.dat"; # TODO use stage not table 165 open (GNUDAT, ">$dataFile"); 169 166 170 167 my $query = $self->{_db}->prepare(<<SQL); … … 175 172 DATE_FORMAT(MIN(timestamp),'$self->{_dateFormat}'), 176 173 TIME_TO_SEC(TIMEDIFF(max(timestamp ), min(timestamp))) 177 FROM $ table174 FROM $stage 178 175 WHERE label LIKE '$label' 179 176 AND timestamp >= '$fromTime' AND timestamp <= '$toTime'; … … 191 188 SELECT 192 189 DATE_FORMAT(timestamp, '$self->{_dateFormat}'), pending, faults, processed-$minProcessed 193 FROM $ table190 FROM $stage 194 191 WHERE label LIKE '$label' 195 192 AND timestamp >= '$fromTime' AND timestamp <= '$toTime' … … 204 201 my ($timestamp, $pending, $faults, $processed) = @row; 205 202 # print "'$timestamp' '$pending' '$faults' '$processed'\n"; 206 print $tempFile"$timestamp $pending $faults $processed\n";207 } 208 close( $tempFile);209 210 return $ tempName;203 print GNUDAT "$timestamp $pending $faults $processed\n"; 204 } 205 close(GNUDAT); 206 207 return $dataFile; 211 208 } 212 209 … … 217 214 ########################################################################### 218 215 sub countFaultsInPast { 219 my ($self, $label, $ table, $interval) = @_; # TODO use time not interval216 my ($self, $label, $stage, $interval) = @_; # TODO use time not interval 220 217 221 218 # get earliest time for this label 222 219 my $query = $self->{_db}->prepare(<<SQL); 223 220 SELECT GREATEST(MIN(timestamp), now() - INTERVAL $interval) 224 FROM $ table221 FROM $stage 225 222 WHERE label LIKE '$label'; 226 223 SQL … … 231 228 $query = $self->{_db}->prepare(<<SQL); 232 229 SELECT faults 233 FROM $ table230 FROM $stage 234 231 WHERE label LIKE '$label' 235 232 AND timestamp <= '$timestamp' LIMIT 1; … … 246 243 ########################################################################### 247 244 sub countPendingNow { 248 my ($self, $label, $ table) = @_;245 my ($self, $label, $stage) = @_; 249 246 250 247 my $query = $self->{_db}->prepare(<<SQL); 251 248 SELECT pending - faults 252 FROM $ table249 FROM $stage 253 250 WHERE label LIKE '$label' 254 251 ORDER BY timestamp DESC LIMIT 1; … … 265 262 ########################################################################### 266 263 sub countProcessedPendingAndFaults { 267 my ($self, $label, $ table, $fromTime, $toTime, $processed, $pending, $faults) = @_;264 my ($self, $label, $stage, $fromTime, $toTime, $processed, $pending, $faults) = @_; 268 265 269 266 … … 271 268 SELECT 272 269 pending, faults 273 FROM $ table270 FROM $stage 274 271 WHERE label LIKE '$label' 275 272 AND timestamp >= '$fromTime' AND timestamp <= '$toTime' … … 283 280 SELECT 284 281 MAX(processed) - MIN(processed) 285 FROM $ table282 FROM $stage 286 283 WHERE label LIKE '$label' 287 284 AND timestamp >= '$fromTime' AND timestamp <= '$toTime'; … … 298 295 ########################################################################### 299 296 sub countProcessed { # TODO use time not interval 300 my ($self, $label, $ table, $interval) = @_;297 my ($self, $label, $stage, $interval) = @_; 301 298 302 299 my $query = $self->{_db}->prepare(<<SQL); 303 300 SELECT 304 301 MAX(processed) - MIN(processed) 305 FROM $ table302 FROM $stage 306 303 WHERE label LIKE '$label' 307 304 AND timestamp > (now() - INTERVAL $interval); -
trunk/tools/czartool/Czarplot.pm
r28776 r28783 4 4 use warnings; 5 5 use strict; 6 7 use File::Temp qw(tempfile);8 6 9 7 my @allStages = ("chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist"); … … 100 98 my $outputFile = createImageFileName($self, $label, undef, "h"); 101 99 102 my ($tempFile, $inputFile) = tempfile( "/tmp/czartool_gnuplot_histogram.XXXX", UNLINK => !$self->{_save_temps}); 100 my $inputFile = "/tmp/czarplot_gnuplot_".$label."_h.dat"; # TODO use stage not table 101 open (GNUDAT, ">$inputFile"); 102 103 103 my ($processed, $pending, $faults); 104 104 my $stage = undef; … … 106 106 107 107 $self->{_czarDb}->countProcessedPendingAndFaults($label, $stage, $beginTime, $endTime, \$processed, \$pending, \$faults); 108 print $tempFile"$stage $processed, $pending, $faults\n";109 } 110 111 close( $tempFile);108 print GNUDAT "$stage $processed, $pending, $faults\n"; 109 } 110 111 close(GNUDAT); 112 112 113 113 plotHistogram($self, $inputFile, $outputFile, $label, $beginTime, $endTime);
Note:
See TracChangeset
for help on using the changeset viewer.
