浏览代码

iperf tcp_proxy_server

ithewei 3 年之前
父节点
当前提交
4d8c546642
共有 2 个文件被更改,包括 17 次插入2 次删除
  1. 10 2
      .github/workflows/benchmark.yml
  2. 7 0
      examples/tcp_proxy_server.c

+ 10 - 2
.github/workflows/benchmark.yml

@@ -20,12 +20,13 @@ jobs:
         run: |
           sudo apt update
           sudo apt install libssl-dev
+          sudo apt install iperf
           sudo apt install nginx
 
-      - name: make tinyhttpd httpd wrk
+      - name: make examples
         run: |
           ./configure
-          make tinyhttpd httpd wrk
+          make examples
 
       - name: build echo-servers
         run: |
@@ -35,6 +36,13 @@ jobs:
         run: |
           bash echo-servers/benchmark.sh
 
+      - name: benchmark tcp_proxy_server
+        run: |
+          iperf -s -p 5001 > /dev/null &
+          bin/tcp_proxy_server 1212 127.0.0.1:5001 &
+          iperf -c 127.0.0.1 -p 5001 -l 8K
+          iperf -c 127.0.0.1 -p 1212 -l 8K
+
       - name: webbench
         run: |
           sudo nginx -c /etc/nginx/nginx.conf

+ 7 - 0
examples/tcp_proxy_server.c

@@ -15,6 +15,12 @@
  *                > GET / HTTP/1.1
  *                > Connection: keep-alive
  *                > [Enter]
+ *
+ * @benchmark:    sudo apt install iperf
+ *                iperf -s -p 5001
+ *                bin/tcp_proxy_server 1212 127.0.0.1:5001
+ *                iperf -c 127.0.0.1 -p 5001 -l 8K
+ *                iperf -c 127.0.0.1 -p 1212 -l 8K
  */
 
 #include "hloop.h"
@@ -50,6 +56,7 @@ int main(int argc, char** argv) {
         return -10;
     }
     proxy_port = atoi(argv[1]);
+    if (proxy_port % 1000 == 443) proxy_ssl = 1;
     char* pos = strchr(argv[2], ':');
     if (pos) {
         int len = pos - argv[2];