last LinqPad performance benchmark in this week - something to now about string.Empty and ""

 As we shall learn all life and never retire from learning - today my closed brain read rfm about using benchmarkDotNet in LPad, so  one can benchmark a code snippet by just selecting it and pressing CTRL+SHIT+B 

The tests were done for .Net 5.0, 6.0 and 7.0 framework versions. As you will see, the results are pretty interesting (and I repeated them a few times)  giving us a few conclusions:

  • I was told to use string.Empty instead of "" for performance, not a case in those results, especially for v7.0
  • I am not sure if the benchmark runner has good ability to test those small operations and I even repeated in one case creation of  a string variables, but the results vere proportional.
  • I need to use full BenchmarkDotNet next time to compare those results, but inside I am curious why the is so big change in the timing.
  • I will still use string.Empty as for me it is easier to decode the code when reading





Comments

Popular posts from this blog

can you believe that more code gives ability to add much more faster?

an actual controversy switch vs if chain (a benchmark example using LinqPad 7 free edition), but the real problem was hidden in a different place [refactoring stuff]

an overdose of strings can kill you - really?