Комментарии:
Which IDE are you using?
ОтветитьI see what you did in your random seed… 80085!
ОтветитьMagic
ОтветитьI wonder, can you mutate the list when other iteration methods are used? No side effects expected?
Ответить.ForEach is not a LINQ method it is actually defined on List<T>
ОтветитьWhat a great video and information for iterating a List !! I think that this works with a List of object that has plenty of properties...
ОтветитьImma steal this to my PowerShell
ОтветитьLove these kind of videos, and so well explained!
ОтветитьHey Nick, where is your telegram channel?
ОтветитьWhy isn't this all optimized away? I'd expect all non-parallel versions to perform exactly the same with a properly optimizing compiler/JIT. So what's up here?
ОтветитьHi Nick, when simple iterate over the items it has performance boost in span but when I'm adding additional functionality into it than its performance reduced and 'for' loop has giving slightly better performance over the Span i.e. CollectionMarshal.AsSpan . Please check.
ОтветитьWindows firewall was blocking my benchmark that used `Unsafe.Add(...)`. I was able to get it to stop doing that, but now i'm seeing `AccessViolationExceptions`. can't figure out why that would be the case. shouldn't the for loops `i < span.Length` check prevent an overrun?
ОтветитьGreat content ♥!
ОтветитьHello! At my job, we had an ague with colleagues what is better if you need to represent a collection in your DTO: List or Array. I think array is better. I had my own bunch of arguments about this, but would love to listen to your opinion about this question. Is there any chance you will make a video with close topic?
Ответитьhelp , why cant i use collectionsmarshal, i already added 'using System.Runtime.InteropServices'
ОтветитьExtra way: walk via unconditional (!) "for" loop, exit via catching "OutOfBounds" exception. Removes double-checking of bounds, but introduces overhead from exception handling. May outperform if the list is extremely huge (throw cost is constant and doesn't scale with items count).
Ответитьdat seed doe...😏
ОтветитьHi, great video! its so usefull. Thanks. I have a question, how can i implement it in async method? what is the best practices in async?
ОтветитьHi Nick. I tried this using Rider in macOS with the arm64 version of .NET 7 and I get very different results. The regular foreach is much slower than For in every test for 100, 100K and 1M. More than double for 1M. Any reasons come to mind?
ОтветитьThere's another way to iterate the span in a async?
Ответить