-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbenchmark_SRVR.js
More file actions
35 lines (27 loc) · 923 Bytes
/
benchmark_SRVR.js
File metadata and controls
35 lines (27 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env node
function rnd (n) { return Math.floor(n* Math.random()) }
var words= "Con diez cañones por banda viento en\
popa a toda vela no corta el mar si no vuela un\
velero bergantín bajel pirata llamado por su bravura\
el temido en todo el mar conocido del uno al otro confín".toLowerCase().split(" ");
var words_length = words.length;
function poema (length, r, curr, prev, l) {
r= [];
l= 0;
while (l < length) {
do curr= words[rnd(words_length)]; while (curr === prev);
r.push(prev= curr);
l+= prev.length+ 1;
}
return r.join(" ");
}
var res= new Buffer("HOLA");
var headers= {Server: "NODE", "Content-Length": res.length};
var port= 8081;
require('http').createServer(callback).listen(port);
function callback (request, response) {
response.writeHead(200, headers);
response.end(res);
//response.end(poema(4096));
}
console.log("NODE Server running on port "+ port);