dhubax

mean_time_simul.awk

Oct 28th, 2020
1,285
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. BEGIN {
  2.   n = 0
  3.   i = 0
  4.   k = 0
  5.   sum = 0
  6.   if (m == 0)
  7.     m = 10
  8.   last_i = -1
  9. }
  10.  
  11. # process begin time
  12. # /seed/ {
  13. #   YMD = $3
  14. #   sub(/-/, " ", YMD)
  15. #   sub(/-/, " ", YMD)
  16. #   HMS = substr($4, 0, 8)
  17. #   sub(/:/, " ", HMS)
  18. #   sub(/:/, " ", HMS)
  19. #   x = YMD FS HMS
  20. #   time = mktime(x)
  21. # }
  22.  
  23. /spec: analysis done!/ {
  24.   X[i] = $(NF - 1)
  25.   sum += X[i]
  26.   ma_sum += X[i]
  27.   i++
  28. }
  29.  
  30. i > m && i != last_i {
  31.   ma_sum -= X[i - int(m)]
  32. }
  33.  
  34. i >= m && i != last_i {
  35.   a[++k] = ma_sum/m
  36.   last_i = i
  37. }
  38.  
  39. END {
  40.   now = systime()
  41.   miss_spec = nspec - i
  42.   mean_run = sum/i
  43.   if (i < m) { ma_run = mean_run; m = i } else { ma_run = a[k] }
  44.   total_mean_time = mean_run*nspec
  45.   missing_time_mean_run = miss_spec*mean_run
  46.   end_time_mean_run = now + missing_time_mean_run
  47.   missing_time_movavg_run = miss_spec*ma_run
  48.   end_time_movavg_run = now + missing_time_movavg_run
  49.   print "number of analyzed spectra: " i
  50.   print "mean run time: " mean_run
  51.   print "mean time last " m " runs: " ma_run
  52.   print "predicted simulation end using mean run time: " strftime("%F %T", end_time_mean_run)
  53.   print "predicted simulation end using mean last " m " runs time: " strftime("%F %T", end_time_movavg_run)
  54. }
  55.  
RAW Paste Data