瀏覽代碼

Add Throughput params

Murat Dogan 4 年之前
父節點
當前提交
1c702a1f7f
共有 2 個文件被更改,包括 43 次插入1 次删除
  1. 37 1
      examples/client-benchmark/parse_cl.cpp
  2. 6 0
      examples/client-benchmark/parse_cl.h

+ 37 - 1
examples/client-benchmark/parse_cl.cpp

@@ -50,6 +50,9 @@ Cmdline::Cmdline (int argc, char *argv[]) // ISO C++17 not allowed: throw (std::
     {"webSocketPort", required_argument, NULL, 'x'},
     {"webSocketPort", required_argument, NULL, 'x'},
     {"durationInSec",required_argument,NULL,'d'},
     {"durationInSec",required_argument,NULL,'d'},
     {"noSend", no_argument, NULL, 'o'},
     {"noSend", no_argument, NULL, 'o'},
+    {"enableThroughputSet", no_argument, NULL, 'p'},
+    {"throughtputSetAsKB",required_argument,NULL,'r'},
+    {"bufferSet",required_argument,NULL,'b'},
     {"help", no_argument, NULL, 'h'},
     {"help", no_argument, NULL, 'h'},
     {NULL, 0, NULL, 0}
     {NULL, 0, NULL, 0}
   };
   };
@@ -65,9 +68,12 @@ Cmdline::Cmdline (int argc, char *argv[]) // ISO C++17 not allowed: throw (std::
   _h = false;
   _h = false;
   _d = 300;
   _d = 300;
   _o = false;
   _o = false;
+  _p = false;
+  _r = 300;
+  _b = 10;
 
 
   optind = 0;
   optind = 0;
-  while ((c = getopt_long (argc, argv, "s:t:w:x:d:enhvo", long_options, &optind)) != - 1)
+  while ((c = getopt_long (argc, argv, "s:t:w:x:d:r:b:enhvop", long_options, &optind)) != - 1)
     {
     {
       switch (c)
       switch (c)
         {
         {
@@ -129,6 +135,30 @@ Cmdline::Cmdline (int argc, char *argv[]) // ISO C++17 not allowed: throw (std::
           _o = true;
           _o = true;
           break;
           break;
 
 
+        case 'p':
+          _p = true;
+          break;
+
+        case 'r':
+          _r = atoi (optarg);
+          if (_r <= 0)
+            {
+              std::string err;
+              err += "parameter range error: r must be > 0";
+              throw (std::range_error(err));
+            }
+          break;
+
+        case 'b':
+          _b = atoi (optarg);
+          if (_b <= 0)
+            {
+              std::string err;
+              err += "parameter range error: b must be > 0";
+              throw (std::range_error(err));
+            }
+          break;
+
         case 'h':
         case 'h':
           _h = true;
           _h = true;
           this->usage (EXIT_SUCCESS);
           this->usage (EXIT_SUCCESS);
@@ -174,6 +204,12 @@ libdatachannel client implementing WebRTC Data Channels with WebSocket signaling
           Benchmark duration in seconds.\n\
           Benchmark duration in seconds.\n\
    [ -n ] [ --noSend ] (type=FLAG)\n\
    [ -n ] [ --noSend ] (type=FLAG)\n\
           Do NOT send message (Only Receive, for one-way testing purposes).\n\
           Do NOT send message (Only Receive, for one-way testing purposes).\n\
+   [ -p ] [ --enableThroughputSet ] (type=FLAG)\n\
+          Send a constant data per second (KB). See throughtputSetAsKB and bufferSet params.\n\
+   [ -r ] [ --throughtputSetAsKB ] (type=INTEGER, range>0...INT_MAX, default=300)\n\
+          Send constant data per second (KB).\n\
+   [ -b ] [ --bufferSet ] (type=INTEGER, range>0...INT_MAX, default=10)\n\
+          Set internal buffer as bufferSet*throughtputSetAsKB/100.\n\
    [ -h ] [ --help ] (type=FLAG)\n\
    [ -h ] [ --help ] (type=FLAG)\n\
           Display this help and exit.\n";
           Display this help and exit.\n";
     }
     }

+ 6 - 0
examples/client-benchmark/parse_cl.h

@@ -42,6 +42,9 @@ private:
   bool _h;
   bool _h;
   int _d;
   int _d;
   bool _o;
   bool _o;
+  bool _p;
+  int _r;
+  int _b;
 
 
   /* other stuff to keep track of */
   /* other stuff to keep track of */
   std::string _program_name;
   std::string _program_name;
@@ -66,6 +69,9 @@ public:
   bool h () const { return _h; }
   bool h () const { return _h; }
   int durationInSec () const { return _d; }
   int durationInSec () const { return _d; }
   bool noSend () const { return _o; }
   bool noSend () const { return _o; }
+  bool enableThroughputSet () const { return _p; }
+  int throughtputSetAsKB() const { return _r;}
+  int bufferSet() const { return _b;}
 };
 };
 
 
 #endif
 #endif