Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <zmq.hpp>
- #include <messages.pb.h>
- #include <sys/time.h>
- #include <unistd.h>
- using namespace google::protobuf::io;
- using namespace std;
- inline double fmicrotime(){
- struct timeval tim;
- gettimeofday(&tim, NULL);
- return tim.tv_sec+(tim.tv_usec/1000000.0);
- }
- int main(int argc, char *argv[]){
- GOOGLE_PROTOBUF_VERIFY_VERSION;
- zmq::context_t context(1);
- zmq::socket_t socket(context, ZMQ_REQ);
- socket.connect("tcp://localhost:4444");
- double start = fmicrotime();
- for(int i=0; i<100000; i++){
- zmq::message_t request(100);
- zmq::message_t response;
- memset (request.data(), 0, 100);
- // Wait for next request from client
- socket.send(request);
- socket.recv(&response);
- }
- cout << "Time consumed is " << (fmicrotime() - start) << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment