Improve idle benchmarks
[platform/upstream/nodejs.git] / benchmark / idle_server.js
1 net = require('net');
2 connections = 0;
3
4 var errors = 0;
5
6 server = net.Server(function (socket) {
7
8   socket.on('error', function () {
9     errors++; 
10   });
11
12 });
13
14 server.listen(9000);
15
16 var oldConnections, oldErrors;
17
18 setInterval(function () {
19   if (oldConnections != server.connections) {
20     oldConnections = server.connections;
21     console.log("SERVER %d connections: %d", process.pid, server.connections);
22   }
23
24   if (oldErrors != errors) {
25     oldErrors = errors;
26     console.log("SERVER %d errors: %d", process.pid, errors);
27   }
28 }, 1000);
29