/tests/bench.sh

http://github.com/nicolasff/webdis · Shell · 71 lines · 56 code · 14 blank · 1 comment · 3 complexity · 04db41fd3f7f96039a1b77413d96583c MD5 · raw file

  1. #!/bin/bash
  2. CLIENTS=100
  3. REQUESTS=100000
  4. HOST=$WEBDIS_HOST
  5. PORT=$WEBDIS_PORT
  6. [ -n $HOST ] && HOST=127.0.0.1
  7. [ -n $PORT ] && PORT=7379
  8. info() {
  9. echo "Testing on $HOST:$PORT with $CLIENTS clients in parallel, for a total of $REQUESTS requests per benchmark."
  10. }
  11. once() {
  12. curl -q http://$HOST:$PORT/$1 1> /dev/null 2> /dev/null
  13. }
  14. bench() {
  15. NUM=`ab -k -c $CLIENTS -n $REQUESTS http://$HOST:$PORT/$1 2>/dev/null | grep "#/sec" | sed -e "s/[^0-9.]//g"`
  16. echo -ne $NUM
  17. }
  18. test_ping() {
  19. echo -en "PING: "
  20. bench "PING"
  21. echo " requests/sec."
  22. }
  23. test_set() {
  24. echo -en "SET(hello,world): "
  25. bench "SET/hello/world"
  26. echo " requests/sec."
  27. }
  28. test_get() {
  29. echo -en "GET(hello): "
  30. bench "GET/hello"
  31. echo " requests/sec."
  32. }
  33. test_incr() {
  34. once "DEL/hello"
  35. echo -en "INCR(hello): "
  36. bench "INCR/hello"
  37. echo " requests/sec."
  38. }
  39. test_lpush() {
  40. once "DEL/hello"
  41. echo -en "LPUSH(hello,abc): "
  42. bench "LPUSH/hello/abc"
  43. echo " requests/sec."
  44. }
  45. test_lrange() {
  46. echo -en "LRANGE(hello,$1,$2): "
  47. bench "LRANGE/hello/$1/$2"
  48. echo " requests/sec."
  49. }
  50. info
  51. test_ping
  52. test_set
  53. test_get
  54. test_incr
  55. test_lpush
  56. test_lrange 0 10
  57. test_lrange 0 100