Guest User

Untitled

a guest
Jan 17th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <zmq.hpp>
  3. #include <messages.pb.h>
  4. #include <sys/time.h>
  5. #include <unistd.h>
  6.  
  7. using namespace google::protobuf::io;
  8. using namespace std;
  9.  
  10. inline double fmicrotime(){
  11. struct timeval tim;
  12. gettimeofday(&tim, NULL);
  13. return tim.tv_sec+(tim.tv_usec/1000000.0);
  14. }
  15.  
  16. int main(int argc, char *argv[]){
  17. GOOGLE_PROTOBUF_VERIFY_VERSION;
  18. zmq::context_t context(1);
  19. zmq::socket_t socket(context, ZMQ_REQ);
  20.  
  21. socket.connect("tcp://localhost:4444");
  22. double start = fmicrotime();
  23. for(int i=0; i<100000; i++){
  24. zmq::message_t request(100);
  25. zmq::message_t response;
  26.  
  27. memset (request.data(), 0, 100);
  28.  
  29. // Wait for next request from client
  30. socket.send(request);
  31.  
  32. socket.recv(&response);
  33. }
  34. cout << "Time consumed is " << (fmicrotime() - start) << endl;
  35. return 0;
  36. }
Add Comment
Please, Sign In to add comment