Commit 1c086d0
authored
Add batching with IMemoryOwner<T> and related tests (#49)
* Add batching with IMemoryOwner<T> and related tests
Introduced a new feature for batching results as `IMemoryOwner<T>` to improve memory management. Updated `.editorconfig` for better code style. Modified `SpecialTests.cs` to correct the expected count. Added documentation and comments in `Extensions.Batch.cs`. Updated `BatchingChannelReader.cs` with new methods and classes for batching. Added comprehensive unit tests in `BatchTests.Memory.cs` and `BatchTests.Queue.cs` to ensure the new batching methods work correctly under various conditions.
* Add benchmarks for batching methods and update batch creation
Added a new project `Open.ChannelExtensions.Benchmarks` to the
solution, including a `BatchDrain` class to measure performance
of different batching methods. Updated `Batch` extension methods
to include an optional `batchFactory` parameter. Modified
`BatchingChannelReader` to use `batchFactory` for batch creation.
Added benchmark tests in `BatchDrain.cs` for list-based,
queue-based, and memory-pooled batching methods. Updated solution
file to include the new benchmark project. Added `Program.cs` to
run benchmarks using `BenchmarkDotNet`.
* Refactor BatchDrain and update Join methods
Refactored `BatchDrain` class in `BatchDrain.cs` by removing `_noOpTarget`, `NoOp`, and `GlobalCleanup`. Updated benchmark methods to use `Join` with a `true` parameter and static lambda for `ReadAll`. Modified `BatchListDrainPooled` and `BatchQueueDrainPooled` to use `Join` with recycler action.
In `Extensions.Join.cs`, updated `JoiningChannelReader` to accept an optional `recycler` action. Added `QueueJoiningChannelReader` and `MemoryJoiningChannelReader` for `Queue<T>` and `IMemoryOwner<T>`. Updated `Join` methods to support new types and optional `recycler` action. Added `TryDequeue` for `Queue<T>` to support .NET Standard 2.0.1 parent 27a2c57 commit 1c086d0
File tree
11 files changed
+1267
-71
lines changed- Open.ChannelExtensions.Benchmarks
- Open.ChannelExtensions.Tests
- Open.ChannelExtensions
- Readers
11 files changed
+1267
-71
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
| 96 | + | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | | - | |
| 146 | + | |
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
0 commit comments