Browse Source

Sum up bytes sent. Print and refresh it every epoch.

Sajin Sasy 1 year ago
parent
commit
b2e7257589
3 changed files with 25 additions and 0 deletions
  1. 20 0
      App/net.cpp
  2. 4 0
      App/net.hpp
  3. 1 0
      App/start.cpp

+ 20 - 0
App/net.cpp

@@ -179,6 +179,26 @@ void NodeIO::recv_commands(
         });
 }
 
+
+uint64_t NodeIO::reset_bytes_sent()
+{
+    uint64_t b_sent = bytes_sent;
+    bytes_sent = 0;
+    return b_sent;
+}
+
+uint64_t NetIO::reset_bytes_sent()
+{
+    uint64_t total=0;
+    for(size_t i = 0; i<nodeios.size(); i++) {
+        if(nodeios[i].has_value()) {
+            total+=((nodeios[i].value()).reset_bytes_sent());
+        }
+    }
+
+    return total;
+}
+
 /*
     Receive clients dropped off messages, i.e. a CLIENT_MESSAGE_BUNDLE
 */

+ 4 - 0
App/net.hpp

@@ -126,6 +126,8 @@ public:
 
     // Close the socket
     void close() { sock.close(); }
+
+    uint64_t reset_bytes_sent();
 };
 
 class NetIO {
@@ -175,6 +177,8 @@ public:
 
     // Close all the sockets
     void close();
+
+    uint64_t reset_bytes_sent();
 };
 
 extern NetIO *g_netio;

+ 1 - 0
App/start.cpp

@@ -184,6 +184,7 @@ static void route_clients_test(NetIO &netio)
         unsigned long diff = end - start;
 
         printf("client_count = %ld\n", client_count);
+        printf("bytes_sent = %ld\n", netio.reset_bytes_sent());
         printf("Epoch %d time: %lu.%06lu s\n", i, diff/1000000, diff%1000000);
 
         // Sleep for the rest of the epoch interval