thomas пре 4 година
родитељ
комит
c7869a4f6f
1 измењених фајлова са 12 додато и 1 уклоњено
  1. 12 1
      src/ua-stress-test/main.cpp

+ 12 - 1
src/ua-stress-test/main.cpp

@@ -27,6 +27,7 @@ char *cfg_OpcUa_ServerEndpoint;
 using namespace std;
 
 bool stop = false; // when set to true, the client threads terminate
+int overallRequests = 0;
 
 void workerThread()
 {
@@ -71,12 +72,14 @@ void workerThread()
     chrono::system_clock::time_point endTime = chrono::system_clock::now();
     UA_Client_disconnect(client);
     UA_Client_delete(client);
+    overallRequests += i;
 
     cout << "Thread " << threadId << " terminating. ";
     cout << "Statistics: " << endl;
     cout << "\tRequests sent: " << i << endl;
     cout << "\tRuntime(ms): " << (std::chrono::duration_cast<std::chrono::milliseconds>(endTime-startTime)).count() << endl;
-    cout << "\tRequests sent per s: " << ((double)i) / (std::chrono::duration_cast<std::chrono::milliseconds>(endTime-startTime)).count() * 1000.0 << endl;}
+    cout << "\tRequests sent per s: " << ((double)i) / (std::chrono::duration_cast<std::chrono::milliseconds>(endTime-startTime)).count() * 1000.0 << endl;
+}
 
 int main(int argc, char **argv) {
     printf("This is the ua-stress-test\n");
@@ -114,6 +117,7 @@ int main(int argc, char **argv) {
         return EXIT_FAILURE;
     }
     
+    chrono::system_clock::time_point startTime = chrono::system_clock::now();
     // start a thread for each connection
     list<thread> threadList;
     for (int i = 0; i < cfg_NumberOfConnections; i++) {  // loop repeats every intervalUs microseconds
@@ -130,6 +134,13 @@ int main(int argc, char **argv) {
     for (it = threadList.begin(); it != threadList.end(); ++it){
         it->join();
     }
+    chrono::system_clock::time_point endTime = chrono::system_clock::now();
+
+    cout << "Overall Statistics: " << endl;
+    cout << "\tRequests sent: " << overallRequests << endl;
+    cout << "\tRuntime(ms): " << (std::chrono::duration_cast<std::chrono::milliseconds>(endTime-startTime)).count() << endl;
+    cout << "\tRequests sent per s: " << ((double)overallRequests) / (std::chrono::duration_cast<std::chrono::milliseconds>(endTime-startTime)).count() * 1000.0 << endl;
+
 
     return EXIT_SUCCESS;
 }