title: ZeroMQ with czmq showing wild swings in performance tests
body: <p>ZeroMQ with czmq is displaying some worrying performance. Timed results differ by a factor of almost 20. Specifically, in the following example, test times range from about 7ms up to 150ms!? </p>
  
  <p>Based on the provided <code>czmq</code> "grassland" [1] test examples, I'm sending a string like <code>abcdefghijklmnopqrstuvwxyz</code> 1000x to the consumer. </p>
  
  <p>Anyone know why this might be?</p>
  
  <p><strong>Minimal, complete, and verifiable example</strong></p>
  
  <p>Based on the <code>grasslands</code> example. Producer and consumer broken into separate files/processes.</p>
  
  <p><em>Subject</em></p>
  
  <pre><code>#include &lt;czmq.h&gt;
  #include &lt;sys/time.h&gt;
  #include &lt;string&gt;
  #include &lt;iostream&gt;
  
  int main (void)
  {
      struct timeval start, end;
  
      //  Create and bind server socket
      zsock_t *server = zsock_new (ZMQ_PUSH);
      zsock_set_linger(server, 10000);
      zsock_bind (server, "tcp://*:9000");
      // Set the string to send
      const std::string s = "abcdefghijklmnopqrstuvwxyz";
  
      // Timestamp start, send 1000x, timetamp end.
      gettimeofday(&amp;start, NULL);
      for (int i=0; i&lt;1000; ++i) {
          zstr_send (server, s.c_str());
      }
      gettimeofday(&amp;end, NULL);
  
      printf("%06ld\n", (long) start.tv_usec);
      printf("%06ld\n", (long) end.tv_usec);
  
      zsock_destroy (&amp;server);
      return 0;
  }
  </code></pre>
  
  <p><em>Observer</em></p>
  
  <pre><code>#include &lt;czmq.h&gt;
  #include &lt;stdio.h&gt;
  
  int main (void)
  {
      zsock_t *client = zsock_new (ZMQ_PULL);
      zsock_connect (client, "tcp://127.0.0.1:9000");
  
      while(1) {
          char *message = zstr_recv (client);
          printf("%s\n", message);
          free (message);
      }
  
      zsock_destroy (&amp;client);
      return 0;
  }
  </code></pre>
  
  <p><em>Five Runs</em></p>
  
  <pre><code>$ pub
  745709
  868642
  
  $ pub
  487869
  643882
  
  $ pub
  564730
  572683
  
  $ pub
  865532
  873030
  
  $ pub
  356007
  500260
  </code></pre>
  
  <p><strong>References</strong></p>
  
  <ol>
  <li><a href="https://github.com/zeromq/czmq/tree/master/examples/security" rel="nofollow noreferrer">https://github.com/zeromq/czmq/tree/master/examples/security</a></li>
  </ol>