From d1cc5599b665c63fe4f636c9a6d68d4d89d234b9 Mon Sep 17 00:00:00 2001 From: Quentin Homareau Date: Sun, 19 Nov 2017 13:02:48 +0100 Subject: [PATCH] Fix NodeJS benchmark Former-commit-id: a1d87cf3a3f4790b9e392dc3c100180284286797 --- _benchmarks/expressjs/app.js | 29 +++++++++++++++++++---------- _benchmarks/expressjs/package.json | 3 ++- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/_benchmarks/expressjs/app.js b/_benchmarks/expressjs/app.js index db4c4587..d26e050a 100644 --- a/_benchmarks/expressjs/app.js +++ b/_benchmarks/expressjs/app.js @@ -1,14 +1,23 @@ process.env.NODE_ENV = 'production'; -const express = require('express'); -const app = express(); +const express = require('express'); +const createWorker = require('throng') -app.get('/api/values/:id', function (req, res) { - res.send('value'); -}); -app.listen(5000, function () { - console.log( - 'Now listening on: http://localhost:5000\nApplication started. Press CTRL+C to shut down.' - ) -}); \ No newline at end of file +createWorker(createWebServer) + +function createWebServer() +{ + const app = express(); + + app.get('/api/values/:id', function (req, res) { + res.send('value'); + }); + + app.listen(5000, function () { + console.log( + 'Now listening on: http://localhost:5000\nApplication started. Press CTRL+C to shut down.' + ) + }); + +} \ No newline at end of file diff --git a/_benchmarks/expressjs/package.json b/_benchmarks/expressjs/package.json index 4916ae06..c5f53166 100644 --- a/_benchmarks/expressjs/package.json +++ b/_benchmarks/expressjs/package.json @@ -9,6 +9,7 @@ "author": "Gerasimos (Makis) Maropoulos ", "license": "ISC", "dependencies": { - "express": "^4.16.0" + "express": "^4.16.0", + "throng": "4.0.0" } }