Created
June 2, 2016 10:09
-
-
Save Dviejopomata/06b74bb6a7c602c782e63794733a5a30 to your computer and use it in GitHub Desktop.
Prueba para ver la influencia del número de rutas en node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var app = express(); | |
var process = require("process"); | |
// nombre del modulo | |
var nombreapp = "gt" | |
var args = process.argv.slice(2); | |
// creación de rutas | |
var k = (modulo, rutas) => | |
{ | |
var r1 = express.Router(); | |
app.use("/"+nombreapp +"/" + modulo, r1) | |
rutas.forEach(i => { | |
r1.get('/'+i, function (req, res) { | |
res.send(modulo + i); | |
}); | |
}) | |
} | |
// creación de tantas rutas como indica el argumento pasado por la linea | |
// comandos | |
// usage node main.js 100 | |
// pasar el ab -n 10000 -c 2 http://localhost:3000/gt/modulo3/d | |
for (var i = 0; i < parseInt(args[0]); i++) | |
{ | |
k("modulo"+i,["a","b","c","d","e"]); | |
} | |
app.listen(3000, function () { | |
console.log('Example app listening on port 3000!'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment