[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[paho-dev] Throughput of the Paho C library
|
Hi,
I was just wondering what the throughput of MQTT messages would be
when using the Paho C library. To do so I modified the
synchronous/asynchronous "publish" samples slightly:
In MQTTClient_publish.c:
8<========================
...
while (true)
{
MQTTClient_publishMessage(client, TOPIC, &pubmsg, &token);
if (MQTTClient_waitForCompletion(client, token, TIMEOUT) !=
MQTTCLIENT_SUCCESS)
{
break;
}
struct timeval tv;
gettimeofday(&tv, nullptr);
std::cout << "Message " << std::setfill(' ') << std::setw(4) <<
cnt << " with delivery token " << std::setfill(' ') << std::setw(4) <<
token <<
" delivered @ " << tv.tv_sec << "." << std::setfill('0') <<
std::setw(6) << tv.tv_usec << std::endl;
cnt++;
}
...
8<========================
In MQTTClient_publish_async.c:
8<========================
...
while (true)
{
MQTTClient_publishMessage(client, TOPIC, &pubmsg, &token);
struct timeval tv;
gettimeofday(&tv, nullptr);
std::cout << "Message " << std::setfill(' ') << std::setw(4) <<
cnt << " with delivery token " << std::setfill(' ') << std::setw(4) <<
token <<
" delivered @ " << tv.tv_sec << "." << std::setfill('0') <<
std::setw(6) << tv.tv_usec << std::endl;
cnt++;
}
...
8<========================
The maximum number of messages per second I could manage to send using
the Paho library was exactly 10. The bottleneck seems to be in
MQTTClient_yield() in both the synchronous and the asynchronous
approach due to either a call to MQTTClient_sleep() or the do-while
loop.
Before digging deeper into the code: is there any reason for this? I
guess that I simply overlooked something ...
Thanks for any hints,
Rainer