benchmark.sh 1.3 KB

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