check_time.sh 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/bash
  2. LOG_DIR=$1
  3. export LOG_N=`find $LOG_DIR -name "*.log" | wc -l`
  4. export break_point=20
  5. echo ""
  6. echo "Log directory : $LOG_DIR"
  7. echo "Total number of log files : $LOG_N"
  8. echo "Number of file for CPU real time check: $break_point"
  9. sum_urqmd=0
  10. sum_runMC=0
  11. sum_reco=0
  12. sum_sqr_urqmd=0
  13. sum_sqr_runMC=0
  14. sum_sqr_reco=0
  15. counter=0
  16. find $LOG_DIR -name "*.log" | while IFS= read -r line; do
  17. grep_urqmd0=`cat $line | grep 'real'`
  18. grep_urqmd1=${grep_urqmd0:4}
  19. grep_urqmd2=${grep_urqmd1%m*s}
  20. if [ -z "$grep_urqmd2" ]; then continue; fi
  21. time_urqmd=$(( $grep_urqmd2 * 60 ))
  22. grep_runMC0=`cat $line | grep 'RealTime='`
  23. grep_runMC1=${grep_runMC0#R*=}
  24. time_runMC=${grep_runMC1%%.*s}
  25. if [ -z "$time_runMC" ]; then continue; fi
  26. grep_reco0=`cat $line | grep 'Real time'`
  27. time_reco0=${grep_reco0:10}
  28. time_reco1=${time_reco0%%.*}
  29. time_reco=${time_reco1%% *}
  30. if [ -z "$time_reco" ]; then continue; fi
  31. ((counter=counter+1))
  32. echo "$counter : t_urqmd = $time_urqmd; t_runMC = $time_runMC; t_reco = $time_reco"
  33. ((sum_urqmd=sum_urqmd+time_urqmd))
  34. ((sum_runMC=sum_runMC+time_runMC))
  35. ((sum_reco=sum_reco+time_reco))
  36. ((sum_sqr_urqmd=sum_sqr_urqmd+time_urqmd*time_urqmd))
  37. ((sum_sqr_runMC=sum_sqr_runMC+time_runMC*time_runMC))
  38. ((sum_sqr_reco=sum_sqr_reco+time_reco*time_reco))
  39. if [[ $counter -eq $break_point ]] || [[ $counter -eq $LOG_N ]]; then
  40. time_total=$(( $time_urqmd + $time_runMC + $time_reco ))
  41. avg_urqmd=$(echo "scale=2;$sum_urqmd / $counter" | bc)
  42. avg_runMC=$(echo "scale=2;$sum_runMC / $counter" | bc)
  43. avg_reco=$(echo "scale=2;$sum_reco / $counter" | bc)
  44. avg_total=$(echo "scale=2;$avg_urqmd + $avg_runMC + $avg_reco" | bc)
  45. avg_total_hr=$(echo "scale=2;$avg_total / 3600" | bc)
  46. avg_sqr_urqmd=$(echo "scale=2;$sum_sqr_urqmd / $counter" | bc)
  47. avg_sqr_runMC=$(echo "scale=2;$sum_sqr_runMC / $counter" | bc)
  48. avg_sqr_reco=$(echo "scale=2;$sum_sqr_reco / $counter" | bc)
  49. sigm_urqmd=$(echo "scale=2;sqrt(($avg_sqr_urqmd - $avg_urqmd * $avg_urqmd))" | bc)
  50. sigm_runMC=$(echo "scale=2;sqrt(($avg_sqr_runMC - $avg_runMC * $avg_runMC))" | bc)
  51. sigm_reco=$(echo "scale=2;sqrt(($avg_sqr_reco - $avg_reco * $avg_reco))" | bc)
  52. sigm_total=$(echo "scale=2;sqrt($sigm_urqmd * $sigm_urqmd + $sigm_runMC * $sigm_runMC + $sigm_reco * $sigm_reco)" | bc)
  53. sigm_urqmd_min=$(echo "scale=2;sqrt(($avg_sqr_urqmd - $avg_urqmd * $avg_urqmd)) / 60" | bc)
  54. sigm_runMC_hr=$(echo "scale=2;sqrt(($avg_sqr_runMC - $avg_runMC * $avg_runMC)) / 3600" | bc)
  55. sigm_reco_hr=$(echo "scale=2;sqrt(($avg_sqr_reco - $avg_reco * $avg_reco)) / 3600" | bc)
  56. sigm_total_hr=$(echo "scale=2;sqrt($sigm_urqmd * $sigm_urqmd + $sigm_runMC * $sigm_runMC + $sigm_reco * $sigm_reco) / 3600" | bc)
  57. echo "Averaged cpu real time:"
  58. echo "Urqmd step: $(echo "scale=2;$avg_urqmd / 60" | bc) +- $sigm_urqmd_min minutes"
  59. echo "RunMC step: $(echo "scale=2;$avg_runMC / 3600" | bc) +- $sigm_runMC_hr hours"
  60. echo "Reco step : $(echo "scale=2;$avg_reco / 3600" | bc) +- $sigm_reco_hr hours"
  61. echo "Total : $avg_total_hr +- $sigm_total_hr hours"
  62. echo ""
  63. break
  64. fi
  65. done