0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/benchmark/idle_server.js
Minwoo Jung 4126441013 benchmark: add a constant declaration for net
Constant declaration for `net` is omitted in `idle_server.js`
Add a constant declaration for constant `net`

PR-URL: https://github.com/nodejs/node/pull/3950
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
2016-01-29 20:40:35 +09:00

32 lines
599 B
JavaScript

'use strict';
const net = require('net');
var connections = 0;
var errors = 0;
var server = net.Server(function (socket) {
socket.on('error', function () {
errors++;
});
});
//server.maxConnections = 128;
server.listen(9000);
var oldConnections, oldErrors;
setInterval(function () {
if (oldConnections != server.connections) {
oldConnections = server.connections;
console.log("SERVER %d connections: %d", process.pid, server.connections);
}
if (oldErrors != errors) {
oldErrors = errors;
console.log("SERVER %d errors: %d", process.pid, errors);
}
}, 1000);