SO CSharp
81 subscribers
1.43K photos
73 videos
80 links
Some stuff about about software development and related (devops, cs, ai, etc.). Stolen memes (mostly), some rare #random_PoK (random Piece of Knowledge), stream notifications. Also #weekendmeme
Download Telegram
❀2🀣2😁1
πŸ’―4❀1
😁6πŸ‘1
πŸ’―4🀣2
😁5❀2
This channel was never meant to be just about stolen memes and jokes. One of the goals was to share some random pieces of knowledge (#random_PoK 😁) that I come across. Since I mostly work with .NET, they’ll likely be .NET-related β€” but we’ll see.

So, here's one of them β€” a niche but interesting Task.WhenEach method. Added in .NET 9, it allows iterating over tasks as they complete via the async enumerable it returns. Here's a basic example:

List<Task<string>> tasks = [ .. ]; // some tasks

await foreach (var completed in Task.WhenEach(tasks))
{
Console.WriteLine(completed.Result);
}


I haven't found many production use cases for this yet but one I can imagine is processing a subset of tasks until some condition is met β€” similar to this SO question, which otherwise would require more verbose code.

I also composed a simple benchmark which showed no significant runtime difference compared to Task.WhenAll. However, the higher completed work items count and lock contentions are worth noting:
| Method       | Mean     | Error    | StdDev   | Completed Work Items | Lock Contentions | Allocated |
|------------- |---------:|---------:|---------:|---------------------:|-----------------:|----------:|
| TaskWhenAll | 15.58 ms | 0.086 ms | 0.081 ms | 11.0000 | - | 3.99 KB |
| TaskWhenEach | 15.53 ms | 0.068 ms | 0.061 ms | 16.6250 | 0.0156 | 3.82 KB |


That said, benchmarks like this are synthetic, so always test your actual workload on real hardware. There's also the question of how applicable microbenchmarking is to parallelized code 😊.

#csharp #dotnet
πŸ‘6πŸ₯°1
Those are the only meaningful numbers regarding the #php experience 😁

#belittlinglangs
❀5🀣2
😁3πŸ’―2❀1
😁6
πŸ’―4❀1😒1
I have a great business idea! 😁

#ai #startup
😁5
Forwarded from SO CSharp
❀3
❀3🌚2
gurustron is online!
Small stream - SO and remembering Apache Ignite SIMD stuff
https://www.twitch.tv/gurustron
❀2
😁6❀1
❀3🌚2
😁2πŸ’―1