1
0
ithewei 4 жил өмнө
parent
commit
072526ac31

+ 2 - 1
echo-servers/benchmark.sh

@@ -5,6 +5,7 @@ port=2000
 connections=100
 duration=10
 threads=2
+sendbytes=1024
 
 while getopts 'h:p:c:d:t:' opt
 do
@@ -80,7 +81,7 @@ sleep 1
 
 for ((p=$sport+1; p<=$port; ++p)); do
     echo -e "\n==============$p====================================="
-    bin/pingpong_client -H $host -p $p -c $connections -d $duration -t $threads
+    bin/pingpong_client -H $host -p $p -c $connections -d $duration -t $threads -b $sendbytes
     sleep 1
 done
 

+ 8 - 5
echo-servers/pingpong_client.cpp

@@ -15,7 +15,7 @@ static const char detail_options[] = R"(
   -c <connections>  Number of connections, default: 1000
   -d <duration>     Duration of test, default: 10s
   -t <threads>      Number of threads, default: 4
-  -b <bytes>        Bytes of send buffer, default: 1024
+  -b <bytes>        Bytes of send buffer, default: 4096
 )";
 
 static int connections = 1000;
@@ -25,7 +25,7 @@ static int threads = 4;
 static bool verbose = false;
 static const char* host = "127.0.0.1";
 static int port = 0;
-static int sendbytes = 1024;
+static int sendbytes = 4096;
 static void* sendbuf = NULL;
 
 static std::atomic<int> connected_num(0);
@@ -38,6 +38,11 @@ static void print_help() {
     printf("Options:\n%s\n", detail_options);
 }
 
+static void print_cmd() {
+    printf("Running %ds test @ %s:%d\n", duration, host, port);
+    printf("%d threads and %d connections, send %d bytes each time\n", threads, connections, sendbytes);
+}
+
 static void print_result() {
     printf("total readcount=%llu readbytes=%llu\n",
         (unsigned long long)total_readcount,
@@ -115,9 +120,7 @@ int main(int argc, char** argv) {
     }
     sendbuf = malloc(sendbytes);
 
-    printf("[%s:%d] %d threads %d connections run %ds\n",
-        host, port,
-        threads, connections, duration);
+    print_cmd();
 
     EventLoopThreadPool loop_threads(threads);
     loop_threads.start(true);