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

+ 10 - 4
src/ua-stress-test/main.cpp

@@ -51,8 +51,9 @@ void workerThread()
     unsigned long intervalUs = 1.0 / ((double)cfg_OpcUaReadsPerConnectionPerS) * 1000000.0;
     UA_Variant value;
     UA_DateTime raw_date; 
-    UA_DateTimeStruct dts; 
-    for(int i = 0; !stop; i++) // loop repeats every intervalUs microseconds
+    UA_DateTimeStruct dts;
+    int i = 0;
+    for(; !stop; i++) // loop repeats every intervalUs microseconds
     {
         std::this_thread::sleep_until(startTime + chrono::microseconds(i * intervalUs));
         retval = UA_Client_readValueAttribute(client, nodeId, &value);
@@ -67,10 +68,15 @@ void workerThread()
             return;
         }
     }
+    chrono::system_clock::time_point endTime = chrono::system_clock::now();
     UA_Client_disconnect(client);
+    UA_Client_delete(client);
 
-    cout << "Thread " << threadId << " terminating" << endl;
-}
+    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;}
 
 int main(int argc, char **argv) {
     printf("This is the ua-stress-test\n");