Annotation of capa/capa51/CapaTools/duration.rpt.pl, revision 1.1
1.1 ! albertel 1: #!/usr/local/bin/perl
! 2:
! 3: require('getopts.pl');
! 4:
! 5: sub S_Enterpath {
! 6: local($notdone,$path);
! 7:
! 8: $notdone = 1;
! 9: while ($notdone) {
! 10: print "Please enter the CLASS absolute path:\n";
! 11: $path = <>; chomp($path);
! 12: if( $path =~ /\/$/ ) {
! 13: $Rfullpath = "$path" . "records";
! 14: $Dfullpath = "$path" . "records/duration.db";
! 15:
! 16: } else {
! 17: $Rfullpath = "$path" . "/records";
! 18: $Dfullpath = "$path" . "/records/duration.db";
! 19:
! 20: }
! 21: if( -d $path ) {
! 22: if( -d $Rfullpath ) {
! 23: if( -f $Dfullpath ) {
! 24: $notdone = 0;
! 25: } else {
! 26: print "File [$Dfullpath] does not exist!\n";
! 27: }
! 28: } else {
! 29: print "Directory [$Rfullpath] does not exist!\n";
! 30: }
! 31: } else {
! 32: print "Directory [$path] does not exist!\n";
! 33: }
! 34:
! 35: }
! 36: return ($path);
! 37: }
! 38:
! 39: sub S_ScanDB {
! 40: local($filename)=@_;
! 41: local($line_cnt)=0;
! 42: local($s_num,$tty,$b_date,$e_date);
! 43: local($hr,$mm,$ss,$ss_cnt);
! 44: local($i, $j, @S_cnt);
! 45: local($ylow, $yavg, $yhigh);
! 46: open(IN, "<$filename") || die "Cannot open $filename file!";
! 47: open(OUT, ">$Out_file") || die "Cannot open $Out_file file!";
! 48: $min_sec = 1000;
! 49: while (<IN>) {
! 50: $line_cnt++;
! 51: chomp();
! 52: ($s_num,$tty,$b_date,$e_date) = split(/\t/);
! 53: if( $line_cnt == 1 ) {
! 54: $start_time = $b_date;
! 55: }
! 56: ($hr,$mm,$ss,$ylow) = S_DiffDate($start_time,$b_date);
! 57: ($hr,$mm,$ss,$yhigh) = S_DiffDate($start_time,$e_date);
! 58: $yavg = ($ylow + $yhigh) / 2;
! 59: $ss_cnt = $yhigh - $ylow;
! 60: $min_sec = ($min_sec < $ss_cnt ? $min_sec : $ss_cnt);
! 61: $s_idx = int($ss_cnt / 100);
! 62: $S_cnt[$s_idx]++;
! 63: print OUT "$line_cnt\t$yavg\t$ylow\t$yhigh\n";
! 64: # print "$s_num,($hr:$mm:$ss,$ss_cnt)\n";
! 65:
! 66: }
! 67: close(IN) || die "Cannot close $filename file!";
! 68: close(OUT) || die "Cannot close $Out_file file!";
! 69:
! 70: print "minimal number of seconds = $min_sec\n";
! 71: for($i=0;$i<=$#S_cnt;$i++) {
! 72: $j= $i * 100;
! 73: print "$j\t$S_cnt[$i]\n" if $S_cnt[$i] > 0;
! 74: }
! 75: print "minimal number of seconds = $min_sec\n";
! 76: }
! 77: ## 012345678901
! 78: ## Wed Jan 8 14:38:06 1997
! 79: ## Fri Jan 17 00:34:30 1997,Fri Jan 17 00:36:25 1997
! 80: %Mon = ( 'Jan' => 0, 'Feb' => 1, 'Mar' => 2, 'Apr' => 3, 'May' => 4, 'Jun' => 5,
! 81: 'Jul' => 6, 'Aug' => 7, 'Sep' => 8, 'Oct' => 9, 'Nov' => 10, 'Dec' => 11 );
! 82: @mdoy = ( 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365);
! 83:
! 84: sub S_DiffDate {
! 85: local($a_str,$b_str)=@_;
! 86: local($hrmmss_astr,$hrmmss_bstr);
! 87: local($modd_astr,$modd_bstr);
! 88: local($mo_a,$dd_a,$hr_a,$mm_a,$ss_a);
! 89: local($mo_b,$dd_b,$hr_b,$mm_b,$ss_b);
! 90: local($sec_cnt);
! 91: local($dsec,$dmm,$dmm_cnt,$dhr_cnt);
! 92:
! 93: $modd_astr = substr($a_str,4,6);
! 94: $hrmmss_astr = substr($a_str,11,8);
! 95: $modd_bstr = substr($b_str,4,6);
! 96: $hrmmss_bstr = substr($b_str,11,8);
! 97: $mo_a = substr($modd_astr,0,3); $dd_a = substr($modd_astr,4,2);
! 98: $mo_b = substr($modd_bstr,0,3); $dd_b = substr($modd_bstr,4,2);
! 99: ($hr_a,$mm_a,$ss_a) = split(/:/, $hrmmss_astr);
! 100: ($hr_b,$mm_b,$ss_b) = split(/:/, $hrmmss_bstr);
! 101: $adoy = $mdoy[$Mon{$mo_a}] + $dd_a;
! 102: $bdoy = $mdoy[$Mon{$mo_b}] + $dd_b;
! 103: $sec_cnt = ($bdoy - $adoy)*24*60*60 + ($hr_b - $hr_a)*60*60 + ($mm_b - $mm_a)*60 + ($ss_b-$ss_a);
! 104: $dsec = $sec_cnt % 60;
! 105: $dmm_cnt = ($sec_cnt - $dsec) / 60;
! 106: $dmm = $dmm_cnt % 60;
! 107: $dhr_cnt = ($dmm_cnt - $dmm) / 60;
! 108:
! 109: return ($dhr_cnt,$dmm,$dsec,$sec_cnt);
! 110: }
! 111:
! 112:
! 113: $Out_file = '/usr/user1/capadvt/CAPA_SRC/4.5/pProj/dur.out';
! 114:
! 115:
! 116: S_Enterpath();
! 117:
! 118: S_ScanDB("$Dfullpath");
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>