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
Fabric React Primer on Components, Controls and Theming
Will SpieringWill Spiering  |  
Nov 12, 2019
React is one of the most used and beloved JavaScript libraries for building user interfaces. There's no shortage of UI frameworks out there to help make developing great React apps quicker and simpler. You may have heard of a couple of the really popular ones like React Bootstrap or...
Blog Article
Using Hooks to Reactify a Plain JavaScript Library: A Walkthrough
Andrew PetersenAndrew Petersen  |  
Aug 06, 2019
React Hooks make it really easy to wrap a vanilla JavaScript library with a React component so you can easily reuse it throughout your app and stay in "React Mode".In this walkthrough I'll be focusing on a single library, Shave.js, but the techniques and ideas should be applicable...
Blog Article
Azure Tips & Tricks: Application Insights Snapshot Debugger
Todd TaylorTodd Taylor  |  
May 21, 2019
A painful memory that is burned into my developer-brain is a production support issue for a .NET web API that I wrote years ago. I worked for a large retailer at the time, and the bug was preventing electronic pricing signs from displaying the most up-to-date price for hundreds of products at...
Blog Article
Creating and Installing Project Templates in .NET Core
Ben BuhrBen Buhr  |  
Apr 30, 2019
In my previous blog article, we examined the .NET Core Command Line Interface (CLI). As part of that, we saw that templates in .NET Core can be very useful. Templates in .NET Core are very easy to create, and there already are a ton of very helpful ones available. They allow us to quickly get an...
Blog Article
Developing on a Raspberry Pi using Gulpjs
Eric DitterEric Ditter  |  
Jan 15, 2019
Developing on one machine and running on another is a tedious process, but sometimes you need to when a library has different features for ARM vs x64 (and then there are always the Windows vs Linux issues). This was the issue I had when I was working on a Raspberry Pi project using Python...