run_common.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0
  3. RUN_BENCH="sudo ./bench -w3 -d10 -a"
  4. function header()
  5. {
  6. local len=${#1}
  7. printf "\n%s\n" "$1"
  8. for i in $(seq 1 $len); do printf '='; done
  9. printf '\n'
  10. }
  11. function subtitle()
  12. {
  13. local len=${#1}
  14. printf "\t%s\n" "$1"
  15. }
  16. function hits()
  17. {
  18. echo "$*" | sed -E "s/.*hits\s+([0-9]+\.[0-9]+ ± [0-9]+\.[0-9]+M\/s).*/\1/"
  19. }
  20. function drops()
  21. {
  22. echo "$*" | sed -E "s/.*drops\s+([0-9]+\.[0-9]+ ± [0-9]+\.[0-9]+M\/s).*/\1/"
  23. }
  24. function percentage()
  25. {
  26. echo "$*" | sed -E "s/.*Percentage\s=\s+([0-9]+\.[0-9]+).*/\1/"
  27. }
  28. function ops()
  29. {
  30. echo -n "throughput: "
  31. echo -n "$*" | sed -E "s/.*throughput\s+([0-9]+\.[0-9]+ ± [0-9]+\.[0-9]+\sM\sops\/s).*/\1/"
  32. echo -n -e ", latency: "
  33. echo "$*" | sed -E "s/.*latency\s+([0-9]+\.[0-9]+\sns\/op).*/\1/"
  34. }
  35. function local_storage()
  36. {
  37. echo -n "hits throughput: "
  38. echo -n "$*" | sed -E "s/.* hits throughput\s+([0-9]+\.[0-9]+ ± [0-9]+\.[0-9]+\sM\sops\/s).*/\1/"
  39. echo -n -e ", hits latency: "
  40. echo -n "$*" | sed -E "s/.* hits latency\s+([0-9]+\.[0-9]+\sns\/op).*/\1/"
  41. echo -n ", important_hits throughput: "
  42. echo "$*" | sed -E "s/.*important_hits throughput\s+([0-9]+\.[0-9]+ ± [0-9]+\.[0-9]+\sM\sops\/s).*/\1/"
  43. }
  44. function total()
  45. {
  46. echo "$*" | sed -E "s/.*total operations\s+([0-9]+\.[0-9]+ ± [0-9]+\.[0-9]+M\/s).*/\1/"
  47. }
  48. function summarize()
  49. {
  50. bench="$1"
  51. summary=$(echo $2 | tail -n1)
  52. printf "%-20s %s (drops %s)\n" "$bench" "$(hits $summary)" "$(drops $summary)"
  53. }
  54. function summarize_percentage()
  55. {
  56. bench="$1"
  57. summary=$(echo $2 | tail -n1)
  58. printf "%-20s %s%%\n" "$bench" "$(percentage $summary)"
  59. }
  60. function summarize_ops()
  61. {
  62. bench="$1"
  63. summary=$(echo $2 | tail -n1)
  64. printf "%-20s %s\n" "$bench" "$(ops $summary)"
  65. }
  66. function summarize_local_storage()
  67. {
  68. bench="$1"
  69. summary=$(echo $2 | tail -n1)
  70. printf "%-20s %s\n" "$bench" "$(local_storage $summary)"
  71. }
  72. function summarize_total()
  73. {
  74. bench="$1"
  75. summary=$(echo $2 | tail -n1)
  76. printf "%-20s %s\n" "$bench" "$(total $summary)"
  77. }