Skip to content

Commit

Permalink
benchmark: fix tcp bench after internal api change
Browse files Browse the repository at this point in the history
Fix up the tcp raw benchmarks after an internal API change.

PR-URL: #495
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information
yosuke-furukawa authored and bnoordhuis committed Jan 18, 2015
1 parent 50177fb commit 3abfb56
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
7 changes: 5 additions & 2 deletions benchmark/net/tcp-raw-c2s.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ var bench = common.createBenchmark(main, {
});

var TCP = process.binding('tcp_wrap').TCP;
var TCPConnectWrap = process.binding('tcp_wrap').TCPConnectWrap;
var WriteWrap = process.binding('stream_wrap').WriteWrap;
var PORT = common.PORT;

var dur;
Expand Down Expand Up @@ -91,7 +93,7 @@ function client() {
}

var clientHandle = new TCP();
var connectReq = {};
var connectReq = new TCPConnectWrap();
var err = clientHandle.connect(connectReq, '127.0.0.1', PORT);

if (err)
Expand All @@ -108,7 +110,8 @@ function client() {
};

function write() {
var writeReq = { oncomplete: afterWrite };
var writeReq = new WriteWrap();
writeReq.oncomplete = afterWrite;
var err;
switch (type) {
case 'buf':
Expand Down
14 changes: 9 additions & 5 deletions benchmark/net/tcp-raw-pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ var bench = common.createBenchmark(main, {
});

var TCP = process.binding('tcp_wrap').TCP;
var TCPConnectWrap = process.binding('tcp_wrap').TCPConnectWrap;
var WriteWrap = process.binding('stream_wrap').WriteWrap;
var PORT = common.PORT;

var dur;
Expand Down Expand Up @@ -51,14 +53,15 @@ function server() {
if (nread < 0)
fail(nread, 'read');

var writeReq = { async: false };
var writeReq = new WriteWrap();
writeReq.async = false;
err = clientHandle.writeBuffer(writeReq, buffer);

if (err)
fail(err, 'write');

writeReq.oncomplete = function(status, handle, req) {
if (status)
writeReq.oncomplete = function(status, handle, req, err) {
if (err)
fail(err, 'write');
};
};
Expand Down Expand Up @@ -88,7 +91,7 @@ function client() {
}

var clientHandle = new TCP();
var connectReq = {};
var connectReq = new TCPConnectWrap();
var err = clientHandle.connect(connectReq, '127.0.0.1', PORT);
var bytes = 0;

Expand Down Expand Up @@ -121,7 +124,8 @@ function client() {
};

function write() {
var writeReq = { oncomplete: afterWrite };
var writeReq = new WriteWrap();
writeReq.oncomplete = afterWrite;
var err;
switch (type) {
case 'buf':
Expand Down
10 changes: 7 additions & 3 deletions benchmark/net/tcp-raw-s2c.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ var bench = common.createBenchmark(main, {
});

var TCP = process.binding('tcp_wrap').TCP;
var TCPConnectWrap = process.binding('tcp_wrap').TCPConnectWrap;
var WriteWrap = process.binding('stream_wrap').WriteWrap;
var PORT = common.PORT;

var dur;
Expand Down Expand Up @@ -68,7 +70,9 @@ function server() {
write();

function write() {
var writeReq = { async: false, oncomplete: afterWrite };
var writeReq = new WriteWrap();
writeReq.async = false;
writeReq.oncomplete = afterWrite;
var err;
switch (type) {
case 'buf':
Expand All @@ -91,7 +95,7 @@ function server() {
}
}

function afterWrite(err, handle, req) {
function afterWrite(status, handle, req, err) {
if (err)
fail(err, 'write');

Expand All @@ -105,7 +109,7 @@ function server() {

function client() {
var clientHandle = new TCP();
var connectReq = {};
var connectReq = new TCPConnectWrap();
var err = clientHandle.connect(connectReq, '127.0.0.1', PORT);

if (err)
Expand Down

0 comments on commit 3abfb56

Please sign in to comment.