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