benchmark_flocking.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/bash
  2. # NetLogo's profiler sucks in the sense that it times one run, then spits out a bunch of junk
  3. # to either a file or stdout. There's no easy abilitiy to parse it.
  4. # the netlogo folder is assumed to be inside the NetLogo folder of this repository, which contains the models
  5. N_RUN=100
  6. NAME_LAUNCHER="./netlogo/netlogo-headless.sh"
  7. NAME_MODEL="Flocking/NetLogo/Flocking.nlogo"
  8. NAME_PARAM="Flocking/NetLogo/parameters_flocking.xml"
  9. NAME_TIMES="Flocking/NetLogo/times.txt"
  10. julia --project=@. seed_netlogo.jl $NAME_PARAM $N_RUN
  11. n_run_model_small () {
  12. sed -i '1d' $NAME_PARAM
  13. (bash $NAME_LAUNCHER --model $NAME_MODEL --setup-file $NAME_PARAM --experiment benchmark_small \
  14. --min-pxcor 0 --max-pxcor 99 --min-pycor 0 --max-pycor 99 --threads 1)
  15. times=()
  16. while IFS= read -r line; do
  17. times+=(`expr $line`)
  18. done < $NAME_TIMES
  19. readarray -t sorted < <(printf '%s\n' "${times[@]}" | sort)
  20. printf "NetLogo Flocking-small Median Time for ${N_RUN} runs (ms): "${sorted[(`expr $N_RUN / 2 + $N_RUN % 2`)]}"\n"
  21. rm $NAME_TIMES
  22. }
  23. n_run_model_large () {
  24. (bash $NAME_LAUNCHER --model $NAME_MODEL --setup-file $NAME_PARAM --experiment benchmark_large \
  25. --min-pxcor 0 --max-pxcor 149 --min-pycor 0 --max-pycor 149 --threads 1)
  26. times=()
  27. while IFS= read -r line; do
  28. times+=(`expr $line`)
  29. done < $NAME_TIMES
  30. readarray -t sorted < <(printf '%s\n' "${times[@]}" | sort)
  31. printf "NetLogo Flocking-large Median Time for ${N_RUN} runs (ms): "${sorted[(`expr $N_RUN / 2 + $N_RUN % 2`)]}"\n"
  32. rm $NAME_TIMES
  33. }
  34. n_run_model_small
  35. n_run_model_large