Why You Should Use .NET Core 2.1 Now

Microsoft just announced the public availability of .NET Core 2.1, the latest version of its .NET Core framework. Forget everything else improved in .NET Core 2.1, but one feature is sufficient for you to make a move to .NET Core 2.1, i.e., performance.

.NET Core 2.1 is the fastest .NET framework ever developed. Here are some of the performance improvement benchmarks via blog.

JIT Improvements

There is major improvement in collection classes. Now JIT can statically determine some virtual invocations and there is about 2.5x improvement in performance.

Method                                        .NET Core 2.0       .NET Core 2.1

EqualityComparerInt                   32 2.2106 ns             0.8725 ns

DictionaryContainsValue             3.419 us                   1.519 us

EnumHasFlag                              14.9214 ns/48 B        0.2932 ns/0 B

LoopBodyLayout                         56.30 ns                     30.49 ns

LoweringTESTtoBT                      1.414 ns                   1.057 ns

BoxingAllocations                          12.444 ns/48 B       1.391 ns/0 B

Threading performance comparison.

Method                                               .NET Core 2.0       .NET Core 2.1

ThreadStatics                                        7.322 ns                   5.269 ns

TimerContention                                     332.8 ms                135.6 ms

SerialCancellationTokenRegistration       95.29 ns/48 B        62.45 ns/0 B

ParallelCancellationTokenRegistration     31.31 ns               18.19 ns

AsyncMethodAwaitInvocation                   20.36 ns/0 B         13.48 ns/0 B

Strings, Formatting, and Other Improvements

Here is a list of some strings and formatting related methods and their performance.

StringIndexOf                                           41.13 ns        15.94 ns

IndexOfAny                                              94.66 ns         38.27 ns

StringToLowerChangesNeeded               187.00 ns       96.29 ns

StringToLowerAlreadyCased                197.21 ns           68.81 ns

StringSplit                                              459.5 ns            305.2 ns

StringConcatCharEnumerable                22.05 us           15.56 us

StringFormat                                           196.1 ns           151.3 ns

StringBuilderAppend                                6.523 ms         3.268 ms

Int32Formatting                                        65.27 ns           34.88 ns

Int32Parsing                                             96.95 ns           76.99 ns

DoubleFormatting                                     448.7 ns           86.8 ns

BigIntegerFormatting                               36.677 us          3.119 us

DateTimeOffsetFormatR                           220.89 ns         64.60 ns

DateTimeOffsetFormatO                         263.45 ns          104.66 ns

ConvertFromBase64String                      45.99 us             29.86 us

ConvertFromBase64Chars                      46.34 us             29.51 us

EnumerateFiles                                        638.0 us             539.5 us

DeriveBytes                                              9.199 ms            8.084 ms

GuidNewGuid                                           7.179 us             1.770 us

RegexCompiled                                        473.7 ns             295.2 ns

As you can see from the above table, .NET Core 2.1 is much faster than its predecessor.


Mindcracker
Founded in 2003, Mindcracker is the authority in custom software development and innovation. We put best practices into action. We deliver solutions based on consumer and industry analysis.