|
@@ -27,6 +27,7 @@ char *cfg_OpcUa_ServerEndpoint;
|
|
|
|
|
|
using namespace std;
|
|
using namespace std;
|
|
|
|
|
|
|
|
+int overallRequests = 0;
|
|
bool stop = false; // when set to true, the client threads terminate
|
|
bool stop = false; // when set to true, the client threads terminate
|
|
|
|
|
|
struct myUserdata {
|
|
struct myUserdata {
|
|
@@ -78,7 +79,8 @@ void workerThread()
|
|
chrono::system_clock::time_point startTime = chrono::system_clock::now();
|
|
chrono::system_clock::time_point startTime = chrono::system_clock::now();
|
|
unsigned long intervalUs = 1.0 / ((double)cfg_OpcUaReadsPerConnectionPerS) * 1000000.0;
|
|
unsigned long intervalUs = 1.0 / ((double)cfg_OpcUaReadsPerConnectionPerS) * 1000000.0;
|
|
UA_UInt32 reqId = 0;
|
|
UA_UInt32 reqId = 0;
|
|
- for(int i = 0; !stop; i++) // loop repeats every intervalUs microseconds
|
|
|
|
|
|
+ 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));
|
|
UA_Client_readValueAttribute_async(client,
|
|
UA_Client_readValueAttribute_async(client,
|
|
@@ -92,12 +94,14 @@ void workerThread()
|
|
UA_Client_disconnect(client);
|
|
UA_Client_disconnect(client);
|
|
UA_Client_delete(client);
|
|
UA_Client_delete(client);
|
|
|
|
|
|
|
|
+ overallRequests += i;
|
|
|
|
+
|
|
cout << "Thread " << threadId << " terminating. ";
|
|
cout << "Thread " << threadId << " terminating. ";
|
|
cout << "Statistics: " << endl;
|
|
cout << "Statistics: " << endl;
|
|
- cout << "\tRequests sent: " << reqId << endl;
|
|
|
|
|
|
+ cout << "\tRequests sent: " << i << endl;
|
|
cout << "\tResponses received: " << d.numberOfResponesReceived << endl;
|
|
cout << "\tResponses received: " << d.numberOfResponesReceived << endl;
|
|
cout << "\tRuntime(ms): " << (std::chrono::duration_cast<std::chrono::milliseconds>(endTime-startTime)).count() << endl;
|
|
cout << "\tRuntime(ms): " << (std::chrono::duration_cast<std::chrono::milliseconds>(endTime-startTime)).count() << endl;
|
|
- cout << "\tRequests sent per s: " << ((double)reqId) / (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) {
|
|
int main(int argc, char **argv) {
|
|
@@ -136,6 +140,7 @@ int main(int argc, char **argv) {
|
|
return EXIT_FAILURE;
|
|
return EXIT_FAILURE;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ chrono::system_clock::time_point startTime = chrono::system_clock::now();
|
|
// start a thread for each connection
|
|
// start a thread for each connection
|
|
list<thread> threadList;
|
|
list<thread> threadList;
|
|
for (int i = 0; i < cfg_NumberOfConnections; i++) { // loop repeats every intervalUs microseconds
|
|
for (int i = 0; i < cfg_NumberOfConnections; i++) { // loop repeats every intervalUs microseconds
|
|
@@ -152,6 +157,13 @@ int main(int argc, char **argv) {
|
|
for (it = threadList.begin(); it != threadList.end(); ++it){
|
|
for (it = threadList.begin(); it != threadList.end(); ++it){
|
|
it->join();
|
|
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;
|
|
return EXIT_SUCCESS;
|
|
}
|
|
}
|