benchmark.sh 1.7 KB

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