Skip to content

Use System.Memory package #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 31, 2022
Merged

Use System.Memory package #60

merged 2 commits into from
Mar 31, 2022

Conversation

manigandham
Copy link
Collaborator

@manigandham manigandham commented Mar 31, 2022

Replacing internal ReadOnlySpan class with official .NET System.Memory package. Offload code complexity and maintenance to the runtime.

@manigandham
Copy link
Collaborator Author

Some improvements in stddev and overall in older .NET 4.8 framework


BenchmarkDotNet=v0.13.1, OS=Windows 10.0.22000
AMD Ryzen 9 3900X, 1 CPU, 24 logical and 12 physical cores
.NET SDK=6.0.201
  [Host]     : .NET 5.0.15 (5.0.1522.11506), X64 RyuJIT
  Job-EQFFTP : .NET 5.0.15 (5.0.1522.11506), X64 RyuJIT
  Job-DDTEQA : .NET 6.0.3 (6.0.322.12309), X64 RyuJIT
  Job-BCCEYU : .NET Framework 4.8 (4.8.4470.0), X64 RyuJIT

OutlierMode=DontRemove  MemoryRandomization=True

|               Method |        Job |            Runtime |       Mean |    Error |   StdDev |  Gen 0 | Code Size | Allocated |
|--------------------- |----------- |------------------- |-----------:|---------:|---------:|-------:|----------:|----------:|
|        RoundtripInts | Job-EQFFTP |           .NET 5.0 | 4,087.2 ns | 67.39 ns | 63.04 ns | 0.0610 |      50 B |     512 B |
|       RoundtripLongs | Job-EQFFTP |           .NET 5.0 | 4,523.4 ns | 41.38 ns | 38.71 ns | 0.0610 |   2,900 B |     512 B |
|         RoundtripHex | Job-EQFFTP |           .NET 5.0 | 4,055.6 ns | 23.44 ns | 21.92 ns | 0.1602 |      49 B |   1,344 B |
|         SingleNumber | Job-EQFFTP |           .NET 5.0 | 1,032.3 ns |  7.89 ns |  7.38 ns | 0.0076 |     153 B |      64 B |
| SingleNumberAsParams | Job-EQFFTP |           .NET 5.0 | 1,027.6 ns | 10.46 ns |  9.78 ns | 0.0191 |   1,917 B |     160 B |
|                      |            |                    |            |          |          |        |           |           |
|        RoundtripInts | Job-DDTEQA |           .NET 6.0 | 3,867.4 ns | 40.69 ns | 38.06 ns | 0.0610 |      50 B |     512 B |
|       RoundtripLongs | Job-DDTEQA |           .NET 6.0 | 4,351.9 ns | 60.49 ns | 56.58 ns | 0.0610 |   2,970 B |     512 B |
|         RoundtripHex | Job-DDTEQA |           .NET 6.0 | 3,728.2 ns | 36.21 ns | 33.87 ns | 0.1602 |      49 B |   1,344 B |
|         SingleNumber | Job-DDTEQA |           .NET 6.0 |   994.3 ns | 10.18 ns |  9.52 ns | 0.0076 |     145 B |      64 B |
| SingleNumberAsParams | Job-DDTEQA |           .NET 6.0 |   983.5 ns |  7.69 ns |  7.19 ns | 0.0191 |   1,902 B |     160 B |
|                      |            |                    |            |          |          |        |           |           |
|        RoundtripInts | Job-BCCEYU | .NET Framework 4.8 | 4,714.1 ns | 46.91 ns | 43.88 ns | 0.1221 |      51 B |     794 B |
|       RoundtripLongs | Job-BCCEYU | .NET Framework 4.8 | 5,461.1 ns | 51.52 ns | 48.19 ns | 0.1373 |   4,078 B |     907 B |
|         RoundtripHex | Job-BCCEYU | .NET Framework 4.8 | 5,782.2 ns | 83.79 ns | 78.37 ns | 0.2747 |      52 B |   1,781 B |
|         SingleNumber | Job-BCCEYU | .NET Framework 4.8 | 1,242.5 ns | 15.59 ns | 14.58 ns | 0.0362 |   2,995 B |     241 B |
| SingleNumberAsParams | Job-BCCEYU | .NET Framework 4.8 | 1,240.0 ns |  8.03 ns |  7.51 ns | 0.0362 |   2,995 B |     241 B |



|               Method |        Job |            Runtime |       Mean |    Error |   StdDev |  Gen 0 | Code Size | Allocated |
|--------------------- |----------- |------------------- |-----------:|---------:|---------:|-------:|----------:|----------:|
|        RoundtripInts | Job-TQEESX |           .NET 5.0 | 3,975.3 ns | 33.22 ns | 31.07 ns | 0.0610 |      50 B |     512 B |
|       RoundtripLongs | Job-TQEESX |           .NET 5.0 | 4,434.3 ns | 13.56 ns | 12.69 ns | 0.0610 |   2,710 B |     512 B |
|         RoundtripHex | Job-TQEESX |           .NET 5.0 | 3,996.3 ns | 23.72 ns | 22.19 ns | 0.1602 |      49 B |   1,344 B |
|         SingleNumber | Job-TQEESX |           .NET 5.0 | 1,017.6 ns |  3.60 ns |  3.37 ns | 0.0076 |     153 B |      64 B |
| SingleNumberAsParams | Job-TQEESX |           .NET 5.0 | 1,023.0 ns |  5.37 ns |  5.02 ns | 0.0191 |   1,747 B |     160 B |
|                      |            |                    |            |          |          |        |           |           |
|        RoundtripInts | Job-QSOHIE |           .NET 6.0 | 3,827.3 ns | 34.47 ns | 32.25 ns | 0.0610 |      50 B |     512 B |
|       RoundtripLongs | Job-QSOHIE |           .NET 6.0 | 4,308.9 ns | 23.20 ns | 21.70 ns | 0.0610 |   2,823 B |     512 B |
|         RoundtripHex | Job-QSOHIE |           .NET 6.0 | 3,772.1 ns | 19.21 ns | 17.97 ns | 0.1602 |      49 B |   1,344 B |
|         SingleNumber | Job-QSOHIE |           .NET 6.0 |   973.1 ns |  8.59 ns |  8.03 ns | 0.0076 |     145 B |      64 B |
| SingleNumberAsParams | Job-QSOHIE |           .NET 6.0 |   990.5 ns | 11.80 ns | 11.03 ns | 0.0191 |   1,793 B |     160 B |
|                      |            |                    |            |          |          |        |           |           |
|        RoundtripInts | Job-VHIPKE | .NET Framework 4.8 | 4,483.8 ns | 34.58 ns | 32.34 ns | 0.1221 |      51 B |     794 B |
|       RoundtripLongs | Job-VHIPKE | .NET Framework 4.8 | 5,098.1 ns | 53.84 ns | 50.36 ns | 0.1373 |   2,948 B |     907 B |
|         RoundtripHex | Job-VHIPKE | .NET Framework 4.8 | 5,608.6 ns | 40.65 ns | 38.03 ns | 0.2747 |      52 B |   1,781 B |
|         SingleNumber | Job-VHIPKE | .NET Framework 4.8 | 1,178.6 ns |  8.35 ns |  7.81 ns | 0.0362 |   2,039 B |     241 B |
| SingleNumberAsParams | Job-VHIPKE | .NET Framework 4.8 | 1,170.4 ns |  3.79 ns |  3.54 ns | 0.0362 |   2,039 B |     241 B |

@manigandham manigandham merged commit 92a04d1 into master Mar 31, 2022
@manigandham manigandham deleted the system.memory branch March 31, 2022 23:11
@manigandham manigandham self-assigned this Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant