Back to List

Pi Day: Comparing .NET Core, .NET Classic and Node.js Performance

John Ptacek John Ptacek  |  
Mar 14, 2018
 
In honor of National Pi Day in the US, we are going to revisit an old blog post where we compared the performance of C# to C++.
 
This is a really simple comparison, but we can still learn a few things!
 
We are going to use a VERY slowly converging series to calculate π to 15 decimal points, which takes close to 100 million iterations to accomplish. The formula is the Leibniz Formula and can be represented as a mathematical series as such:
 
pi day equation

Microsoft has been hard at work, rewriting their .NET platform from the version that has powered enterprises over the last 15 years, to a more platform agnostic, open source version called .NET Core.
 
We thought it would be interesting to compare .NET Core calculations to the previous .NET Classic calculation that was written in C#. We also decided to compare the very popular Node.js runtime, which drives a lot of web development, both with NPM for client development and on the server.
 
There were 10 iterations of each code run on Windows 10. You can find the code on Skyline’s Github account at pi-day-leibniz.
 
win10 dot net node classic

As we can see, the performance of .NET Core is pretty impressive on Windows! Three times as fast than .NET Classic and 7 times faster than Node.js. This passes the smell test too. We expect a more modern rewrite of .NET to perform better. Node.js is also an interpreted language, so it will not be as fast as compiled code.
 
We then compared the performance of .NET Core and Node.js across operating systems on the same machine, in this case, Ubuntu 17.10 and Windows 10. Since both code bases are multi-platform, we can see how they compare across OSes.
 
ubuntu dotnet node

Node.js performs slightly better on Ubuntu than it does on Windows. Given that Node.js uses Google’s Chrome JavaScript engine, we would expect similar performances across platforms.
 
Dotnet Core in this instance though is about three times slower on Linux than it is on Windows. This makes sense since Microsoft is the creator of Windows 10 and will have tons of expertise on optimizing application for the operating system.
 

Two takeaways from this Pi Day exercise:

  1. .NET core performance is very impressive. The release of Node.js brought Async processing to the forefront to enable performant API calls. The rest of vendors have been playing catch up, and Microsoft’s catch up with .NET Core is very fast. This is also backed up by much more thorough benchmarks from TechEmpower.
  2. Second, the development landscape is vastly different in the five years since we did a Pi day look at C# and C++ performance in 2013.
Microsoft’s C# classic is not the company’s future direction. They are 100% in on the new .NET Core platform and enabling developers to build things on Windows, Mac or Linux. This is a remarkable turnaround for a company that once called Linux a cancer.
 
Throw in the fact that .NET Core is an Open Source technology, as is Node.js. Microsoft has even Open Source .NET classic. We can see that in the five years since we last looked at performance that Open Source technology has become the standard for developers, with implementations on the developer’s platform of choice. That is outstanding progress for developers.
 
Happy Pi day! Go and write some code!
 
.Net ProgrammingJavaScript

 

Love our Blogs?

Sign up to get notified of new Skyline posts.

 


Related Content


Blog Article
How to Use Azure Search Services
Steven NelsonSteven Nelson  |  
Apr 10, 2018
Azure has a unique service offering aptly named “Azure Search”. This is a search-as-a-service cloud solution that lets you add a rich search service to your apps.   The search service abstracts the complexities of document retrieval through both a REST API and a .NET SDK...
Blog Article
Using SignalR Base Classes in Angular
Eric DitterEric Ditter  |  
Mar 06, 2018
On one of my previous projects I used SignalR extensively in an Angular 1.6 application, and I was using the angular-signalr-hub library to integrate it into the application. It worked very well, but I am moving to the next version of Angular so I wanted to find a way to do it without having to...
Blog Article
Microsoft Build 2017 Day 3 Recap
Brandon MartinezBrandon Martinez  |  
May 13, 2017
Day three of Microsoft Build 2017 did not have a keynote, but that doesn’t mean it ends without content to fill the day. Today will be focused on sessions, “The Hub”, and catching some of the Channel 9 Live production happening right here at the conference. Here’s a...
Blog Article
Microsoft Build 2017 Day 2 Recap
Brandon MartinezBrandon Martinez  |  
May 12, 2017
Another beautiful day in Seattle, and another amazing day at Build 2017! Today started off with another fantastic keynote followed by a wide array of awesome sessions. Here’s my recap of today’s events. Keynote Today’s keynote was heavily focused at improvements and...
Blog Article
Microsoft Build 2017 Day 1 Recap
Brandon MartinezBrandon Martinez  |  
May 11, 2017
I’m very excited to be here in Seattle, Washington to attend the Microsoft Build 2017 conference! It’s an honor to be amongst the geekiest of the geeks in the Microsoft community and to be able to absorb a ton of knowledge over the next few days. I’ll be posting daily recaps of...