123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #!/bin/bash
- LOG_DIR=$1
- export LOG_N=`find $LOG_DIR -name "*.log" | wc -l`
- export break_point=20
- echo ""
- echo "Log directory : $LOG_DIR"
- echo "Total number of log files : $LOG_N"
- echo "Number of file for CPU real time check: $break_point"
- sum_urqmd=0
- sum_runMC=0
- sum_reco=0
- sum_sqr_urqmd=0
- sum_sqr_runMC=0
- sum_sqr_reco=0
- counter=0
- find $LOG_DIR -name "*.log" | while IFS= read -r line; do
- grep_urqmd0=`cat $line | grep 'real'`
- grep_urqmd1=${grep_urqmd0:4}
- grep_urqmd2=${grep_urqmd1%m*s}
- if [ -z "$grep_urqmd2" ]; then continue; fi
- time_urqmd=$(( $grep_urqmd2 * 60 ))
- grep_runMC0=`cat $line | grep 'RealTime='`
- grep_runMC1=${grep_runMC0#R*=}
- time_runMC=${grep_runMC1%%.*s}
- if [ -z "$time_runMC" ]; then continue; fi
- grep_reco0=`cat $line | grep 'Real time'`
- time_reco0=${grep_reco0:10}
- time_reco1=${time_reco0%%.*}
- time_reco=${time_reco1%% *}
- if [ -z "$time_reco" ]; then continue; fi
- ((counter=counter+1))
- echo "$counter : t_urqmd = $time_urqmd; t_runMC = $time_runMC; t_reco = $time_reco"
- ((sum_urqmd=sum_urqmd+time_urqmd))
- ((sum_runMC=sum_runMC+time_runMC))
- ((sum_reco=sum_reco+time_reco))
- ((sum_sqr_urqmd=sum_sqr_urqmd+time_urqmd*time_urqmd))
- ((sum_sqr_runMC=sum_sqr_runMC+time_runMC*time_runMC))
- ((sum_sqr_reco=sum_sqr_reco+time_reco*time_reco))
- if [[ $counter -eq $break_point ]] || [[ $counter -eq $LOG_N ]]; then
- time_total=$(( $time_urqmd + $time_runMC + $time_reco ))
- avg_urqmd=$(echo "scale=2;$sum_urqmd / $counter" | bc)
- avg_runMC=$(echo "scale=2;$sum_runMC / $counter" | bc)
- avg_reco=$(echo "scale=2;$sum_reco / $counter" | bc)
- avg_total=$(echo "scale=2;$avg_urqmd + $avg_runMC + $avg_reco" | bc)
- avg_total_hr=$(echo "scale=2;$avg_total / 3600" | bc)
-
- avg_sqr_urqmd=$(echo "scale=2;$sum_sqr_urqmd / $counter" | bc)
- avg_sqr_runMC=$(echo "scale=2;$sum_sqr_runMC / $counter" | bc)
- avg_sqr_reco=$(echo "scale=2;$sum_sqr_reco / $counter" | bc)
-
- sigm_urqmd=$(echo "scale=2;sqrt(($avg_sqr_urqmd - $avg_urqmd * $avg_urqmd))" | bc)
- sigm_runMC=$(echo "scale=2;sqrt(($avg_sqr_runMC - $avg_runMC * $avg_runMC))" | bc)
- sigm_reco=$(echo "scale=2;sqrt(($avg_sqr_reco - $avg_reco * $avg_reco))" | bc)
- sigm_total=$(echo "scale=2;sqrt($sigm_urqmd * $sigm_urqmd + $sigm_runMC * $sigm_runMC + $sigm_reco * $sigm_reco)" | bc)
- sigm_urqmd_min=$(echo "scale=2;sqrt(($avg_sqr_urqmd - $avg_urqmd * $avg_urqmd)) / 60" | bc)
- sigm_runMC_hr=$(echo "scale=2;sqrt(($avg_sqr_runMC - $avg_runMC * $avg_runMC)) / 3600" | bc)
- sigm_reco_hr=$(echo "scale=2;sqrt(($avg_sqr_reco - $avg_reco * $avg_reco)) / 3600" | bc)
- sigm_total_hr=$(echo "scale=2;sqrt($sigm_urqmd * $sigm_urqmd + $sigm_runMC * $sigm_runMC + $sigm_reco * $sigm_reco) / 3600" | bc)
-
- echo "Averaged cpu real time:"
- echo "Urqmd step: $(echo "scale=2;$avg_urqmd / 60" | bc) +- $sigm_urqmd_min minutes"
- echo "RunMC step: $(echo "scale=2;$avg_runMC / 3600" | bc) +- $sigm_runMC_hr hours"
- echo "Reco step : $(echo "scale=2;$avg_reco / 3600" | bc) +- $sigm_reco_hr hours"
- echo "Total : $avg_total_hr +- $sigm_total_hr hours"
- echo ""
- break
- fi
- done
|