Browse Source

benchmark: fix tcp bench after internal api change

Fix up the tcp raw benchmarks after an internal API change.

PR-URL: https://github.com/iojs/io.js/pull/495
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
v1.8.0-commit
Yosuke Furukawa 10 years ago
committed by Ben Noordhuis
parent
commit
3abfb56f9b
  1. 7
      benchmark/net/tcp-raw-c2s.js
  2. 14
      benchmark/net/tcp-raw-pipe.js
  3. 10
      benchmark/net/tcp-raw-s2c.js

7
benchmark/net/tcp-raw-c2s.js

@ -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;
@ -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)
@ -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':

14
benchmark/net/tcp-raw-pipe.js

@ -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;
@ -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');
};
};
@ -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;
@ -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':

10
benchmark/net/tcp-raw-s2c.js

@ -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;
@ -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':
@ -91,7 +95,7 @@ function server() {
}
}
function afterWrite(err, handle, req) {
function afterWrite(status, handle, req, err) {
if (err)
fail(err, 'write');
@ -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)

Loading…
Cancel
Save