Skip to content

Instantly share code, notes, and snippets.

@timcash
Created April 7, 2011 10:31
Show Gist options
  • Save timcash/907514 to your computer and use it in GitHub Desktop.
Save timcash/907514 to your computer and use it in GitHub Desktop.
a test for publish speed of zeromq in nodejs
var cnt, mes, s, sender, util, zmq;
zmq = require('zeromq');
util = require('util');
s = zmq.createSocket('pub');
s.bind('tcp://127.0.0.1:5559', function(err) {
if (err) {
throw err;
}
util.puts('binding');
});
cnt = 1;
mes = function() {
var data;
data = "" + cnt;
if (cnt % 100 === 0) {
util.puts("sending " + data);
}
s.send(data);
cnt++;
};
sender = setInterval(mes, 1);
process.on('SIGINT', function() {
clearInterval(sender);
s.close();
console.log("Quitting now");
process.exit(1);
});
util.puts('Ready to go!');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment