Closed gfoidl closed 2 years ago
Method PR2 is this PR finally (and it produces almost the best machine code for that task).
PR2
| Method | Mean | Error | StdDev | Ratio | RatioSD | Code Size | Allocated | |------- |---------:|--------:|--------:|------:|--------:|----------:|----------:| | Main | 199.8 ns | 1.98 ns | 1.86 ns | 1.00 | 0.00 | 268 B | - | | PR | 162.3 ns | 0.79 ns | 0.62 ns | 0.81 | 0.01 | 236 B | - | | PR1 | 162.3 ns | 1.32 ns | 1.17 ns | 0.81 | 0.01 | 224 B | - | | PR2 | 155.4 ns | 3.09 ns | 4.13 ns | 0.78 | 0.03 | 216 B | - |
I believe ToS7Conversions is quite ideal, so didn't touch it for now (and for my use case I'm just reading too).
ToS7Conversions
Took a while for me to review, but again thanks for the contribution.
Method
PR2
is this PR finally (and it produces almost the best machine code for that task).I believe
ToS7Conversions
is quite ideal, so didn't touch it for now (and for my use case I'm just reading too).Benchmark code
```c# using System; using System.Buffers.Binary; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Running; BenchmarkRunner.RunMachine Code for .NET 5
```assembly ; Bench.Main() sub rsp,38 xor eax,eax mov [rsp+28],rax lea rdx,[rcx+8] mov r8,[rcx+10] test r8,r8 jne short M00_L00 xor ecx,ecx xor r9d,r9d jmp short M00_L01 M00_L00: lea rcx,[r8+10] mov r9d,[r8+8] M00_L01: lea r8,[rsp+28] mov [r8],rcx mov [r8+8],r9d lea r8,[rsp+28] mov rcx,offset MD_Bench.ConvertToLongArray_Main(Int64[] ByRef, System.ReadOnlySpan`1