Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

benchmark: fix tcp raw benchmarks after internal api change #495

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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