benchmark.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/bin/bash
  2. SCRIPT_DIR=$(cd `dirname $0`; pwd)
  3. cd ${SCRIPT_DIR}/..
  4. killall_echo_servers() {
  5. #sudo killall libevent_echo libev_echo libuv_echo libhv_echo asio_echo poco_echo muduo_echo
  6. if [ $(ps aux | grep _echo | grep -v grep | wc -l) -gt 0 ]; then
  7. ps aux | grep _echo | grep -v grep | awk '{print $2}' | xargs sudo kill -9
  8. fi
  9. }
  10. export LD_LIBRARY_PATH=lib:$LD_LIBRARY_PATH
  11. ip=127.0.0.1
  12. sport=2000
  13. port=$sport
  14. killall_echo_servers
  15. if [ -x bin/libevent_echo ]; then
  16. let port++
  17. bin/libevent_echo $port &
  18. echo "libevent running on port $port"
  19. fi
  20. if [ -x bin/libev_echo ]; then
  21. let port++
  22. bin/libev_echo $port &
  23. echo "libev running on port $port"
  24. fi
  25. if [ -x bin/libuv_echo ]; then
  26. let port++
  27. bin/libuv_echo $port &
  28. echo "libuv running on port $port"
  29. fi
  30. if [ -x bin/libhv_echo ]; then
  31. let port++
  32. bin/libhv_echo $port &
  33. echo "libhv running on port $port"
  34. fi
  35. if [ -x bin/asio_echo ]; then
  36. let port++
  37. bin/asio_echo $port &
  38. echo "asio running on port $port"
  39. fi
  40. if [ -x bin/poco_echo ]; then
  41. let port++
  42. bin/poco_echo $port &
  43. echo "poco running on port $port"
  44. fi
  45. if [ -x bin/muduo_echo ]; then
  46. let port++
  47. bin/muduo_echo $port &
  48. echo "muduo running on port $port"
  49. fi
  50. sleep 1
  51. client=2
  52. time=10
  53. if [ $# -gt 0 ]; then
  54. time=$1
  55. fi
  56. for ((p=$sport+1; p<=$port; ++p)); do
  57. echo -e "\n==============$p====================================="
  58. bin/webbench -q -c $client -t $time $ip:$p
  59. sleep 1
  60. done
  61. killall_echo_servers