hewei.it пре 5 година
родитељ
комит
5d1c82303d
5 измењених фајлова са 36 додато и 16 уклоњено
  1. 4 6
      README.md
  2. 8 3
      echo-servers/benchmark.sh
  3. 19 0
      echo-servers/build.sh
  4. 1 1
      echo-servers/libuv_echo.c
  5. 4 6
      readme_cn.md

+ 4 - 6
README.md

@@ -229,14 +229,12 @@ see config.mk
 
 ### echo-servers
 ```shell
-make libhv
-make webbench
-
 # ubuntu16.04
-sudo apt-get install libevent-dev libev-dev libuv1-dev libboost-dev libasio-dev libpoco-dev
+sudo apt install libevent-dev libev-dev libuv1-dev libboost-dev libboost-system-dev libasio-dev libpoco-dev
 # muduo install => https://github.com/chenshuo/muduo.git
-make echo-servers
-sudo echo-servers/benchmark.sh
+cd echo-servers
+./build.sh
+./benchmark.sh
 ```
 
 **echo-servers/benchmark**<br>

+ 8 - 3
echo-servers/benchmark.sh

@@ -1,8 +1,13 @@
-#! /bin/bash
+#!/bin/bash
+
+SCRIPT_DIR=$(cd `dirname $0`; pwd)
+cd ${SCRIPT_DIR}/..
 
 killall_echo_servers() {
     #sudo killall libevent_echo libev_echo libuv_echo libhv_echo asio_echo poco_echo muduo_echo
-    ps aux | grep _echo | grep -v grep | awk '{print $2}' | xargs sudo kill -9
+    if [ $(ps aux | grep _echo | grep -v grep | wc -l) -gt 0 ]; then
+        ps aux | grep _echo | grep -v grep | awk '{print $2}' | xargs sudo kill -9
+    fi
 }
 
 export LD_LIBRARY_PATH=lib:$LD_LIBRARY_PATH
@@ -58,7 +63,7 @@ fi
 sleep 1
 
 client=2
-time=60
+time=10
 if [ $# -gt 0 ]; then
     time=$1
 fi

+ 19 - 0
echo-servers/build.sh

@@ -0,0 +1,19 @@
+#!/bin/bash
+
+SCRIPT_DIR=$(cd `dirname $0`; pwd)
+cd ${SCRIPT_DIR}/..
+
+# install libevent libev libuv asio poco
+UNAME=$(uname -a)
+case ${UNAME} in
+    *Ubuntu*|*Debian*)
+        sudo apt install libevent-dev libev-dev libuv1-dev libboost-dev libboost-system-dev libasio-dev libpoco-dev;;
+    *Centos*);;
+    *Darwin*);;
+    *);;
+esac
+
+# install muduo => https://github.com/chenshuo/muduo.git
+
+make libhv && sudo make install
+make webbench

+ 1 - 1
echo-servers/libuv_echo.c

@@ -32,7 +32,7 @@ void read_cb(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf) {
     }
     uv_write_req_t* wr = (uv_write_req_t*)malloc(sizeof(uv_write_req_t));
     wr->buf.base = buf->base;
-    wr->buf.len = buf->len;
+    wr->buf.len = nread;
     uv_write(&wr->req, stream, &wr->buf, 1, write_cb);
 }
 

+ 4 - 6
readme_cn.md

@@ -228,14 +228,12 @@ bin/curl -v localhost:8080 --http2
 
 ### echo-servers
 ```shell
-make libhv
-make webbench
-
 # ubuntu16.04
-sudo apt-get install libevent-dev libev-dev libuv1-dev libboost-dev libasio-dev libpoco-dev
+sudo apt install libevent-dev libev-dev libuv1-dev libboost-dev libboost-system-dev libasio-dev libpoco-dev
 # muduo install => https://github.com/chenshuo/muduo.git
-make echo-servers
-sudo echo-servers/benchmark.sh
+cd echo-servers
+./build.sh
+./benchmark.sh
 ```
 
 **echo-servers/benchmark**<br>