I am doing a quick stress test on two (kinda) hello world projects written in node.js and asp.net-core. Both of them are running in production mode and without a logger attached to them. The result is astonishing! ASP.NET core is outperforming node.js app even after doing some extra work whereas the node.js app is just rendering a view.
App 1: http://localhost:3000/nodejs
node.js
Using: node.js, express and vash rendering engine.
The code in this endpoint is
router.get('/', function(req, res, next) {
var vm = {
title: 'Express',
time: new Date()
}
res.render('index', vm);
});
As you can see, it does nothing apart from sending current date via the time
variable to the view.
App 2: http://localhost:5000/aspnet-core
asp.net core
Using: ASP.NET Core, default template targeting dnxcore50
However This app does something other than just rendering a page with a date on it. It generates 5 paragraph of various random texts. This should ideally make this little bit heavier than the nodejs app.
Here is the action method that render this page
[ResponseCache(Location = ResponseCacheLocation.None, NoStore = true)]
[Route("aspnet-core")]
public IActionResult Index()
{
var sb = new StringBuilder(1024);
GenerateParagraphs(5, sb);
ViewData["Message"] = sb.ToString();
return View();
}
Stress test result
Node.js App stress test result
ASP.NET Core App stress test result
Can't believe my eyes! It can't be true that in this basic test asp.net core is way faster than nodejs. Off course this is not the only metric used to measure performance between these two web technologies but I am wondering what am I doing wrong in the node.js side.
Being a professional asp.net developer and wishing to adapt node.js in personal projects, this kind of putting me off - as I'm little paranoid about performance. I always thought node.js is faster than asp.net core (in general) I just want to prove it to myself (to encourage myself in adapting node.js).
Please reply in comment if you want me to include more code snippets.
via IKnowNothingAtAll
No comments:
Post a Comment