Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Prueba para ver la influencia del número de rutas en node.js
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
You can’t perform that action at this time.