summaryrefslogtreecommitdiff
path: root/benchmark/net/net-c2s.js
diff options
context:
space:
mode:
Diffstat (limited to 'benchmark/net/net-c2s.js')
-rw-r--r--benchmark/net/net-c2s.js24
1 files changed, 12 insertions, 12 deletions
diff --git a/benchmark/net/net-c2s.js b/benchmark/net/net-c2s.js
index 4bbea92121..140f9612ab 100644
--- a/benchmark/net/net-c2s.js
+++ b/benchmark/net/net-c2s.js
@@ -1,10 +1,10 @@
// test the speed of .pipe() with sockets
'use strict';
-var common = require('../common.js');
-var PORT = common.PORT;
+const common = require('../common.js');
+const PORT = common.PORT;
-var bench = common.createBenchmark(main, {
+const bench = common.createBenchmark(main, {
len: [102400, 1024 * 1024 * 16],
type: ['utf', 'asc', 'buf'],
dur: [5],
@@ -40,7 +40,7 @@ function main(conf) {
server();
}
-var net = require('net');
+const net = require('net');
function Writer() {
this.received = 0;
@@ -66,8 +66,8 @@ Writer.prototype.prependListener = function() {};
function flow() {
- var dest = this.dest;
- var res = dest.write(chunk, encoding);
+ const dest = this.dest;
+ const res = dest.write(chunk, encoding);
if (!res)
dest.once('drain', this.flow);
else
@@ -87,24 +87,24 @@ Reader.prototype.pipe = function(dest) {
function server() {
- var reader = new Reader();
- var writer = new Writer();
+ const reader = new Reader();
+ const writer = new Writer();
// the actual benchmark.
- var server = net.createServer(function(socket) {
+ const server = net.createServer(function(socket) {
socket.pipe(writer);
});
server.listen(PORT, function() {
- var socket = net.connect(PORT);
+ const socket = net.connect(PORT);
socket.on('connect', function() {
bench.start();
reader.pipe(socket);
setTimeout(function() {
- var bytes = writer.received;
- var gbits = (bytes * 8) / (1024 * 1024 * 1024);
+ const bytes = writer.received;
+ const gbits = (bytes * 8) / (1024 * 1024 * 1024);
bench.end(gbits);
process.exit(0);
}, dur * 1000);