Comparing version 2.4.0 to 2.5.0
@@ -0,1 +1,12 @@ | ||
2.5.0 / 2013-08-20 | ||
================== | ||
* Added testing against Node.js v0.11 [AlexeyKupershtokh] | ||
* Add support for Joyent SmartMachines [JonGretar] | ||
* Use pkg-config on OS X too [blalor] | ||
* Patch for Node 0.11.3 [kkoopa] | ||
* Fix for bind / connect / send problem [kkoopa] | ||
* Fixed multiple bugs in perf tests and changed them to push/pull [ronkorving] | ||
* Add definitions for building on openbsd & freebsd [Minjung] | ||
2.4.0 / 2013-04-09 | ||
@@ -2,0 +13,0 @@ ================== |
@@ -5,4 +5,7 @@ /** | ||
require('set-immediate'); | ||
var EventEmitter = require('events').EventEmitter | ||
, zmq = require('../build/Release/zmq'); | ||
, zmq = require('../build/Release/zmq') | ||
, util = require('util'); | ||
@@ -149,2 +152,3 @@ /** | ||
function Socket(type) { | ||
EventEmitter.call(this); | ||
this.type = type; | ||
@@ -161,3 +165,3 @@ this._zmq = new zmq.Socket(defaultContext(), types[type]); | ||
Socket.prototype.__proto__ = EventEmitter.prototype; | ||
util.inherits(Socket, EventEmitter); | ||
@@ -335,2 +339,5 @@ /** | ||
if(zmq.STATE_CLOSED == this._zmq.state) return; | ||
this._flushing = true; | ||
@@ -349,3 +356,3 @@ try { | ||
do { | ||
emitArgs.push(new Buffer(this._zmq.recv())); | ||
emitArgs.push(this._zmq.recv()); | ||
} while (this._receiveMore); | ||
@@ -355,5 +362,5 @@ | ||
(function(emitArgs) { | ||
process.nextTick(function(){ | ||
setImmediate(function(){ | ||
self.emit.apply(self, emitArgs); | ||
}) | ||
}); | ||
})(emitArgs); | ||
@@ -379,3 +386,2 @@ | ||
} | ||
this._flushing = false; | ||
@@ -382,0 +388,0 @@ }; |
{ | ||
"name": "zmq", | ||
"version": "2.4.0", | ||
"version": "2.5.0", | ||
"description": "Bindings for node.js to zeromq", | ||
"main": "index", | ||
"repository": { | ||
"type" : "git", | ||
"url" : "http://github.com/JustinTulloss/zeromq.node.git" | ||
"type": "git", | ||
"url": "http://github.com/JustinTulloss/zeromq.node.git" | ||
}, | ||
"dependencies": { | ||
"set-immediate": "*" | ||
}, | ||
"devDependencies": { | ||
@@ -50,4 +53,8 @@ "should": "*", | ||
"John Sun (https://github.com/freehaha)", | ||
"Alexey Kupershtokh <alexey.kupershtokh@gmail.com>" | ||
"Alexey Kupershtokh <alexey.kupershtokh@gmail.com>", | ||
"Jon Gretar Borgthorsson (https://github.com/JonGretar)", | ||
"Brian Lalor (https://github.com/blalor)", | ||
"Benjamin Byholm (https://github.com/kkoopa)", | ||
"Alejandro (https://github.com/Minjung)" | ||
] | ||
} |
@@ -1,21 +0,21 @@ | ||
var zmq = require('../') | ||
var assert = require('assert') | ||
var zmq = require('../'); | ||
var assert = require('assert'); | ||
if (process.argv.length != 5) { | ||
console.log('usage: local_lat <bind-to> <message-size> <roundtrip-count>') | ||
process.exit(1) | ||
console.log('usage: local_lat <bind-to> <message-size> <roundtrip-count>'); | ||
process.exit(1); | ||
} | ||
var bind_to = process.argv[2] | ||
var message_size = Number(process.argv[3]) | ||
var roundtrip_count = Number(process.argv[4]) | ||
var counter = 0 | ||
var bind_to = process.argv[2]; | ||
var message_size = Number(process.argv[3]); | ||
var roundtrip_count = Number(process.argv[4]); | ||
var counter = 0; | ||
var rep = zmq.socket('rep') | ||
rep.bindSync(bind_to) | ||
var rep = zmq.socket('rep'); | ||
rep.bindSync(bind_to); | ||
rep.on('message', function (data) { | ||
assert.equal(data.length, message_size, 'message-size did not match') | ||
rep.send(data) | ||
if (++counter === roundtrip_count) rep.close() | ||
assert.equal(data.length, message_size, 'message-size did not match'); | ||
rep.send(data); | ||
if (++counter === roundtrip_count) rep.close(); | ||
}) |
@@ -1,37 +0,41 @@ | ||
var zmq = require('../') | ||
var assert = require('assert') | ||
var zmq = require('../'); | ||
var assert = require('assert'); | ||
if (process.argv.length != 5) { | ||
console.log('usage: local_thr <bind-to> <message-size> <message-count>') | ||
process.exit(1) | ||
console.log('usage: local_thr <bind-to> <message-size> <message-count>'); | ||
process.exit(1); | ||
} | ||
var bind_to = process.argv[2] | ||
var message_size = Number(process.argv[3]) | ||
var message_count = Number(process.argv[4]) | ||
var counter = 0 | ||
var bind_to = process.argv[2]; | ||
var message_size = Number(process.argv[3]); | ||
var message_count = Number(process.argv[4]); | ||
var counter = 0; | ||
var sub = zmq.socket('sub') | ||
sub.bindSync(bind_to) | ||
sub.subscribe('') | ||
var sock = zmq.socket('pull'); | ||
sock.bindSync(bind_to); | ||
var timer = process.hrtime() | ||
var timer; | ||
sub.on('message', function (data) { | ||
assert.equal(data.length, message_size, 'message-size did not match') | ||
if (++counter === message_count) finish() | ||
sock.on('message', function (data) { | ||
if (!timer) { | ||
console.log('started receiving'); | ||
timer = process.hrtime(); | ||
} | ||
assert.equal(data.length, message_size, 'message-size did not match'); | ||
if (++counter === message_count) finish(); | ||
}) | ||
function finish(){ | ||
var endtime = process.hrtime(timer) | ||
var millis = (endtime[0]*1000) + (endtime[1]/1000000) | ||
var throughput = message_count / (millis / 1000) | ||
var megabits = (throughput * message_size * 8) / 1000000 | ||
var endtime = process.hrtime(timer); | ||
var sec = endtime[0] + (endtime[1]/1000000000); | ||
var throughput = message_count / sec; | ||
var megabits = (throughput * message_size * 8) / 1000000; | ||
console.log('message size: %d [B]', message_size) | ||
console.log('message count: %d', message_count) | ||
console.log('mean throughput: %d [msg/s]', throughput.toFixed(0)) | ||
console.log('mean throughput: %d [Mbit/s]', megabits.toFixed(0)) | ||
console.log('overall time: %d secs and %d nanoseconds', endtime[0], endtime[1]) | ||
sub.close() | ||
console.log('message size: %d [B]', message_size); | ||
console.log('message count: %d', message_count); | ||
console.log('mean throughput: %d [msg/s]', throughput.toFixed(0)); | ||
console.log('mean throughput: %d [Mbit/s]', megabits.toFixed(0)); | ||
console.log('overall time: %d secs and %d nanoseconds', endtime[0], endtime[1]); | ||
sock.close(); | ||
} |
@@ -1,44 +0,52 @@ | ||
var zmq = require('../') | ||
var assert = require('assert') | ||
var zmq = require('../'); | ||
var assert = require('assert'); | ||
if (process.argv.length != 5) { | ||
console.log('usage: remote_lat <connect-to> <message-size> <roundtrip-count>') | ||
process.exit(1) | ||
console.log('usage: remote_lat <connect-to> <message-size> <roundtrip-count>'); | ||
process.exit(1); | ||
} | ||
var connect_to = process.argv[2] | ||
var message_size = Number(process.argv[3]) | ||
var roundtrip_count = Number(process.argv[4]) | ||
var message = new Buffer(message_size) | ||
message.fill('h') | ||
var connect_to = process.argv[2]; | ||
var message_size = Number(process.argv[3]); | ||
var roundtrip_count = Number(process.argv[4]); | ||
var message = new Buffer(message_size); | ||
message.fill('h'); | ||
var sendCounter = recvCounter = 0 | ||
var recvCounter = 0; | ||
var req = zmq.socket('req') | ||
req.connect(connect_to) | ||
var req = zmq.socket('req'); | ||
req.connect(connect_to); | ||
var timer = process.hrtime() | ||
var timer; | ||
req.on('message', function (data) { | ||
assert.equal(data.length, message_size, 'message-size did not match') | ||
if (++recvCounter === roundtrip_count) finish() | ||
}) | ||
if (!timer) { | ||
console.log('started receiving'); | ||
timer = process.hrtime(); | ||
} | ||
function finish(){ | ||
var endtime = process.hrtime(timer) | ||
var millis = (endtime[0]*1000) + (endtime[1]/1000000) | ||
assert.equal(data.length, message_size, 'message-size did not match'); | ||
console.log('message size: %d [B]', message_size) | ||
console.log('roundtrip count: %d', roundtrip_count) | ||
console.log('mean latency: %d [msecs]', millis / roundtrip_count * 2) | ||
console.log('overall time: %d secs and %d nanoseconds', endtime[0], endtime[1]) | ||
if (++recvCounter === roundtrip_count) { | ||
finish(); | ||
} else { | ||
send(); | ||
} | ||
}); | ||
function finish() { | ||
var duration = process.hrtime(timer); | ||
var millis = duration[0] * 1000 + duration[1] / 1000000; | ||
console.log('message size: %d [B]', message_size); | ||
console.log('roundtrip count: %d', roundtrip_count); | ||
console.log('mean latency: %d [msecs]', millis / (roundtrip_count * 2)); | ||
console.log('overall time: %d secs and %d nanoseconds', duration[0], duration[1]); | ||
req.close() | ||
} | ||
function send(){ | ||
process.nextTick(function () { | ||
req.send(message) | ||
if (++sendCounter < roundtrip_count) send() | ||
}) | ||
function send() { | ||
req.send(message); | ||
} | ||
send() |
@@ -15,16 +15,24 @@ var zmq = require('../') | ||
console.log(message.length) | ||
var counter = 0 | ||
var pub = zmq.socket('pub') | ||
pub.connect(connect_to) | ||
var sock = zmq.socket('push') | ||
//sock.setsockopt(zmq.ZMQ_SNDHWM, message_count); | ||
sock.connect(connect_to) | ||
function send(){ | ||
process.nextTick(function () { | ||
pub.send(message) | ||
if (++counter < message_count) send() | ||
// else pub.close() // all messages may not be received by local_thr if closed | ||
}) | ||
for (var i = 0; i < message_count; i++) { | ||
sock.send(message) | ||
} | ||
// all messages may not be received by local_thr if closed immediately | ||
setTimeout(function () { | ||
sock.close() | ||
}, 1000); | ||
} | ||
send() | ||
// because of what seems to be a bug in node-zmq, we would lose messages | ||
// if we start sending immediately after calling connect(), so to make this | ||
// benchmark behave well, we wait a bit... | ||
setTimeout(send, 1000); | ||
@@ -58,1 +58,35 @@ [](https://travis-ci.org/JustinTulloss/zeromq.node) | ||
$ make test | ||
## Running benchmarks | ||
Benchmarks are available in the `perf` directory, and have been implemented | ||
according to the zmq documentation: | ||
[How to run performance tests](http://www.zeromq.org/results:perf-howto) | ||
In the following examples, the arguments are respectively: | ||
- the host to connect to/bind on | ||
- message size (in bytes) | ||
- message count | ||
You can run a latency benchmark by running these two commands in two separate | ||
shells: | ||
```sh | ||
node ./local_lat.js tcp://127.0.0.1:5555 1 100000 | ||
``` | ||
```sh | ||
node ./remote_lat.js tcp://127.0.0.1:5555 1 100000 | ||
``` | ||
And you can run throughput tests by running these two commands in two | ||
separate shells: | ||
```sh | ||
node ./local_thr.js tcp://127.0.0.1:5555 1 100000 | ||
``` | ||
```sh | ||
node ./remote_thr.js tcp://127.0.0.1:5555 1 100000 | ||
``` | ||
@@ -25,8 +25,19 @@ | ||
a.bind('tcp://127.0.0.1:5555', function() {}); | ||
var bound = false; | ||
setTimeout(function() { | ||
a.bind('tcp://127.0.0.1:5555', function(e) { | ||
if (e) { | ||
throw e; | ||
} else { | ||
bound = true; | ||
} | ||
}); | ||
var interval = setInterval(function() { | ||
gc(); | ||
b.connect('tcp://127.0.0.1:5555'); | ||
b.send('hello'); | ||
if (bound) { | ||
clearInterval(interval); | ||
b.connect('tcp://127.0.0.1:5555'); | ||
b.send('hello'); | ||
} | ||
}, 100); | ||
@@ -36,3 +47,4 @@ | ||
var timeout = setTimeout(function() { | ||
throw new Error('Timeout'); | ||
}, 1000); | ||
clearInterval(interval); | ||
throw new Error('Timeout\nBound: ' + bound); | ||
}, 5000); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
831446
1364
92
4
1
1
+ Addedset-immediate@*
+ Addedset-immediate@0.1.1(transitive)