- Published on
Choosing the Best OS for .NET Development - Mac vs. Windows Showdown
6 min read- Authors
- Name
- Daniel Mackay
- @daniel_mackay
- Introduction
- Laptops
- Tests
- Code Bases
- Test 1 - IDE Start-Up
- Test 2 - Compiling Code
- Test 3 - Running Code
- Verdict
- Resources
Introduction
I've been developing software on Windows for around 20 years now. I've also been called a 'Microsoft Fanboy' from time to time. š Recently, I've noticed that the majority of the younger guys at the office are all sporting MacBooks. These are very slick looking machines and I'm always impressed by the battery life they give out.
So after all these years on Windows, I decided to buy a MacBook Air 13" as a 'travel device'. Weighing just over 1kg and having a battery live of 18 hours, I thought this would be awesome for flights and conferences.
When news got round the office, one of my colleagues responded with:
The plan was to get a laptop better suited to travelling, while continuing to keep my Dell āworkhorseā as my daily driver.
However, after a bit of use I had a feeling the MacBook Air was running quite a bit faster, so I did some basic tests. Results were surprising so I thought Iād share.
Laptops
MacBook Air | Dell XPS 15 | |
---|---|---|
Screen Size | 13.6" | 15.6" |
CPU | Apple M3 | Intel i9 |
RAM | 24GB | 32GB |
SSD | 512GB | 512GB |
Battery Life | 18 hours | 13 hours (theoretical) |
Weight | 1.24kg | 2.05kg |
Price | $2,699 AUD | $4,371 AUD |
NOTE: The battery life is theoretical and based on the manufacturer's specifications. With the Dell, I get around 5 hours of battery life. I haven't been able to fully test the MacBook Air yet.
Tests
Code Bases
I decided to test the performance of the two laptops on both a small and large code bases:
SSW.CleanArchitecture | SSW.Induction | |
---|---|---|
Project Size | Small | Large |
Files | 241 | 2506 |
Lines of Code | 51169 | 446383 |
NOTE: cloc was used to get the lines of code.
Test 1 - IDE Start-Up
The first test was to open up the IDE. For this test I used Rider which was configured to open the solution automatically. I stopped the test once all analysis and indexing had completed.
I did this 3 times and averaged the results, which are as follows:
NOTE: Graph above was produced by giving ChatGPT a markdown table and asking it to generate a bar graph š¤
Test 2 - Compiling Code
For the builds, I did a clean first, then timed a build and repeated twice.
Building the code with Rider:
Building the code via the .NET CLI:
You might notice that the CLI build time is even higher for SSW.Induction. I believe that is due to a large number of warnings that need to be output to the screen during each build.
Test 3 - Running Code
For the final test, I wanted to see how the performance of a website would compare between Windows and Mac. I decided to do this on the SSW.CleanArchitecture solution only due to simplicity of its setup and use. We will use K6 to do a load test which will determine the maximum number of users and requests per second that the API can handle.
The load test we will use is:
import http from 'k6/http';
import { sleep, check } from 'k6';
import { Rate } from 'k6/metrics';
export const errorRate = new Rate('errors');
export let options = {
insecureSkipTLSVerify: true,
noConnectionReuse: false,
vus: 30, // number of virtual users
duration: '2m', // duration of the test
};
export default function () {
const url = 'https://localhost:7255/heroes';
check(http.get(url), {
'status is 200': (r) => r.status == 200,
}) || errorRate.add(1);
sleep(1);
}
This is a bit of a crude test, but it will give us an idea of the performance difference between the two laptops. What I'm really looking for here is how many requests per second the webserver can handle. The trick here is to continually increase the number of virtual users until the server starts to be able to handle less web requests. Through a bit of experimentation I found 30 VU's on the Mac was the sweet spot, before performance started to degrade.
Let's see what happened!
Windows | Mac | |
---|---|---|
Total Requests | 2502 | 3032 |
Verdict
In every test I did, the results of the Mac far surpassed Windows. I had a suspicion that the Mac would be faster, but the actual results blew me away. I realize these tests are not really comparing 'apples with apples' as the hardware is different, but when you compare the performance to the price, the Mac is a clear winner in terms of both value for money and performance.
I have a long relationship with Windows and Visual Studio. However, I now find myself doing real work on a MacBook and Rider. I find this refreshing and exciting. It's great to know that I have options when it comes to modern .NET Development.
Based on these tests, it seems like the ātravel laptopā is going to now be my ādaily driverā. š
All I need to do now is learn how to use a Macā¦ š