Time for a follow up to my String.Concat vs String.Format Performance post from back in 2014!
I recently found out that string interpolation is not nearly as efficient as I would have thought. I also suspected that it was just doing a string concatenation, but it is actually doing a string format. This leads to a pretty significant performance degradation; the following test runs one million iterations of each.
Number of Args |
Interpolation Milliseconds |
String.Format Milliseconds |
String.Concat Milliseconds |
String Add Milliseconds |
StringBuilder Milliseconds |
---|---|---|---|---|---|
2 | 262 | 260 | 19 | 18 | 34 |
3 | 367 | 367 | 25 | 24 | 35 |
4 | 500 | 513 | 31 | 32 | 41 |
5 | 646 | 635 | 67 | 66 | 44 |
6 | 740 | 723 | 79 | 76 | 49 |
7 | 802 | 819 | 86 | 85 | 52 |
8 | 938 | 936 | 97 | 98 | 58 |
So, what's the lesson? Don't use string interpolation in high performance areas (such as your logger)!
Enjoy,
Tom
And never, ever, use String Add unless they are constant strings.
ReplyDeleteI am a computer science student & these strings, arrays type complex topics are always difficult for me, now I have to get the best dissertation writing help to be able to understand these topics & write on these to complete my dissertation report.
ReplyDeleteThis particular papers fabulous, and My spouse and i enjoy each of the perform that you have placed into this. I’m sure that you will be making a really useful place. I has been additionally pleased. Good perform!
ReplyDelete고스톱
I am always searching online for articles that can help me. There is obviously a lot to know about this. I think you made some good points in Features also. Keep working, great job!
ReplyDelete스포츠토토
All the contents you mentioned in post is too good and can be very useful. I will keep it in mind, thanks for sharing the information keep updating, looking forward for more posts. Thanks!
ReplyDelete한국야동
I like the many blogposts, I seriously liked, I want details about it, since it is rather wonderful., Cheers pertaining to expressing..
ReplyDelete토토사이트
Beautiful story! My friend, let me tell you my... long time ago I was walking on the Street and found a laptop. In the browser, I found a page with title https://www.writemyessays.org/ , this is fantastic! If you necessity some essay writing help, just call them!)
ReplyDeleteI feel very grateful that I read this. It is very helpful and very informative and I really learned a lot from it.
ReplyDeleteUniraj BA 1st Year Result 2022
Uniraj BA 2nd Year Result 2022
Uniraj BA 3rd Year Result 2022
This is a really good read for me, I have to admit that you are one of the best bloggers I have ever seen. Thanks for posting this informative article. buy cheap prescription glasses
ReplyDelete