Monday, December 16, 2019

LINQ2DB vs EF Core Benchmark under .NET Framework 4.8 and Core 3.1

Recently .NET Core 3.1 was released. It's optimized more that .NET Framework and will be its successor soon.

This is why it's interesting to compare them.

Benchmark has done with the same rules.

Hardware: i7-8750H, DDR4-2667.
Software: Win 10 x64, 64 bit, .NET 4.8, Core 3.1, linq2db 2.9.4, EFCore 3.1, ADO for .NET Framework v4.0.30319 (standard), ADO for Core 4.8.0 (nuget package).

Simple TOP 10 query

ORM: LINQ2DB is very good for simple queries, twice better than EF Core. LINQ2DB raw query can be even better than calling manually ADO (might be measurement error).

Platform: Overall performance of Core is just a little bit worse than .NET. Context initialization for Core is slower, but query compilation and mapping are faster than under .NET.

Simple TOP 500 query

ORM: For a little bit less simple queries LINQ2DB is still faster than EF Core but not much.

Platform: Context initialization for Core is slower than for .NET, but overall performance is better.

Complex TOP 10 query

ORM: LINQ2DB is slightly faster than EF Core but difference is just small.

Platform: Core is a little bit faster than .NET but nearly the same.

Complex TOP 500 query

The picture is interesting.

ORM: For complex queries with many rows EF Core sometimes can be faster than LINQ2DB and even ADO.

Conclusion

EF Core is a lot faster now than before.

.NET Core can work faster than .NET Framework when program is written with its optimizations. Such example is EF Core. You can see that ADO (despite it has separate version for Core) and LINQ2DB work different under .NET and Core but this difference is not as big as for EF Core.

EF Core works much faster under .NET Core - it's visible very good on the last picture - only EF Core has significant difference.

Now, with the .NET Core and EF Core both 3.1 they both may be a better choice than LINQ2DB.

EF Core is slightly slower but not much and sometimes even faster.

EF Core also has very good support from a biggest company, unlike LINQ2DB where you cannot count on it.

Another side of the choice is LTS.

.NET Core even LTS has only 3 years of support, unlike .NET Framework that has 10+ years of support (from Windows 10 LTSC version). It doesn't matter and even good if you're going to be in tune with newest tools, but it can be not so good otherwise.

Raw results (Excel).

View project source code at Bitbucket.