Paul,
Here is number of messages as seen by the server in one second. Each
message is 1024 byte excluding tcp/ip and zmq headers. Based on these
numbers and i am getting a throughput of 1.4 Gb/sec.
Enclosed is the source code for the server and the client.
Number of msgs in one second: 189448
Number of msgs in one second: 187253
Number of msgs in one second: 191877
Number of msgs in one second: 189329
Number of msgs in one second: 186831
Number of msgs in one second: 193623
Number of msgs in one second: 193909
Number of msgs in one second: 187524
Number of msgs in one second: 192248
Number of msgs in one second: 188696
Number of msgs in one second: 186850
Number of msgs in one second: 187961
Number of msgs in one second: 201370
Number of msgs in one second: 199532
Number of msgs in one second: 194561
Number of msgs in one second: 190004
Number of msgs in one second: 170991
Number of msgs in one second: 178643
Number of msgs in one second: 185415
Number of msgs in one second: 197018
Number of msgs in one second: 182171
Number of msgs in one second: 184114
Number of msgs in one second: 192708
Number of msgs in one second: 191136
Number of msgs in one second: 196130
Number of msgs in one second: 197735
Number of msgs in one second: 189077
Thank you,
Jim
On Sun, Sep 16, 2012 at 8:04 AM, Chuck Remes <[email protected]> wrote:
> On Sep 15, 2012, at 8:37 PM, Maninder Batth wrote:
>
> > Paul,
> > That was an excellent idea indeed. As i was simply following the first
> example in the guide and developed on top of it, i did not read the api.
> > After going over the socket API, now, instead of how many messages can a
> pub send in a second, i record, how many messages can a consumer get in one
> second.
> > This brought down the number considerably from 4.5GB/sec to 1.5Gb/sec.
> > But its still a mystery, how can i get a number of 1.5Gb over 1Gb
> network ?
>
> Please publish your latest code so we can see how you are calculating
> things now.
>
> cr
>
>
> _______________________________________________
> zeromq-dev mailing list
> [email protected]
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
#include <string>
#include <iostream>
#include "zmq.hpp"
#include "boost/chrono.hpp"
typedef boost::chrono::duration<long, boost::milli> milliseconds;
std::string * makeString(int i);
int main()
{
zmq::context_t context(1);
std::cout << "About to create a socket" << std::endl;
zmq::socket_t socket(context, ZMQ_PUB);
std::cout << "Socket created " << std::endl;
long numOfMsgs =0;
int size = 1024;
std::string *s = makeString(size);
std::cout << "Message is " << std::endl;
std::cout << *s << std::endl;
std::cout << "String length is " << s->length() << std::endl;
zmq::message_t request(size);
memcpy((void *) request.data(),(void *) s, 1024);
socket.connect("tcp://173.229.133.114:55555");
boost::chrono::system_clock::time_point start = boost::chrono::system_clock::now();
milliseconds ms(1000);
boost::chrono::system_clock::time_point end = start + ms;
while(true)
{
do
{
bool success = socket.send(request);
if (success)
numOfMsgs++;
} while(boost::chrono::system_clock::now() < end);
std::cout << "Number of messages send in one sec: " << numOfMsgs << std::endl;
end = boost::chrono::system_clock::now() + ms;
numOfMsgs = 0;
}
return 0;
}
std::string * makeString(int i)
{
char data[1024];
for(int j=0;j<i;j++)
{
data[j] = 'a';
}
std::string *a = new std::string(data, 1024);
return a;
}
#include <zmq.hpp>
#include <string>
#include <iostream>
#include <unistd.h>
#include "boost/chrono.hpp"
typedef boost::chrono::duration<long, boost::milli> milliseconds;
typedef boost::chrono::system_clock::time_point time_point;
using namespace std;
void handleTimeout(long & numOfMsgs, time_point & timeout);
time_point now();
bool isTimeout(time_point earlier);
time_point getNewTimeout();
milliseconds ms(1000); //one second
int main()
{
zmq::context_t context(1);
zmq::socket_t socket(context, ZMQ_SUB);
socket.setsockopt(ZMQ_SUBSCRIBE,"", strlen(""));
socket.bind("tcp://173.229.133.114:55555");
long numOfMsgs = 0;
time_point timeout = getNewTimeout();
do {
zmq::message_t request;
socket.recv(&request);
// cout << "Msg recvd" << endl;
if (isTimeout(timeout))
handleTimeout(numOfMsgs, timeout);
else
numOfMsgs++;
} while (true);
return 0;
}
void handleTimeout(long & numOfMsgs, time_point & timeout)
{
cout << "Number of msgs in one second: " << numOfMsgs++ << endl;
numOfMsgs = 1;
timeout = getNewTimeout();
}
time_point now()
{
return boost::chrono::system_clock::now();
}
bool isTimeout(time_point timeout)
{
return ((now() < timeout) ? false : true);
}
time_point getNewTimeout()
{
return (now() + ms);
}
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev