1
0

benchmark.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/bash
  2. set -eu
  3. # benchmark.sh
  4. export KB=1000
  5. export MB=$((KB*1000))
  6. MAX_UPLOAD_SIZE=$((512*KB))
  7. export CONCURRENCY=5
  8. export BANDWIDTH=$((100*MB/CONCURRENCY))
  9. FILE_SIZES=($((1*KB)) $((10*KB)) $((100*KB)))
  10. echo "Concurrency: $CONCURRENCY"
  11. echo "Bandwidth: $BANDWIDTH"
  12. md_output="# Bulk upload benchmark\n"
  13. md_output+="\n"
  14. md_output+="- Concurrency: $CONCURRENCY\n"
  15. md_output+="- Bandwidth: ${BANDWIDTH}B\n"
  16. md_output+="\n"
  17. md_output+="| Nb | Size (B) | Bundle (sec) | Single (sec) |\n"
  18. md_output+="|---|---|---|---|\n"
  19. requests_count='1 2 3 4 5'
  20. for size in "${FILE_SIZES[@]}"
  21. do
  22. nb=$((MAX_UPLOAD_SIZE/size))
  23. echo "- Upload of $nb tiny file of ${size}B"
  24. echo " - Bundled"
  25. start=$(date +%s)
  26. echo "$requests_count" | xargs -d ' ' -P $CONCURRENCY -I{} ./bulk_upload.sh "$nb" "$size"
  27. end=$(date +%s)
  28. bulk_exec_time=$((end-start))
  29. echo "${bulk_exec_time}s"
  30. echo " - Single"
  31. start=$(date +%s)
  32. echo "$requests_count" | xargs -d ' ' -P $CONCURRENCY -I{} ./single_upload.sh "$nb" "$size"
  33. end=$(date +%s)
  34. single_exec_time=$((end-start))
  35. echo "${single_exec_time}s"
  36. md_output+="| $nb | $size | $bulk_exec_time | $single_exec_time |\n"
  37. done
  38. echo -en "$md_output"