akamsteeg / AtleX.HaveIBeenPwned

A fully async .NET Standard client library for the API of HaveIBeenPwned.com
https://www.nuget.org/packages/AtleX.HaveIBeenPwned/
MIT License
5 stars 0 forks source link

Use more pooled arrays as buffers in the KAnonimityHelper #99

Closed akamsteeg closed 4 months ago

akamsteeg commented 4 months ago

Follow-up for #98. The generated hash can also be stored in a rented array, that would reduce allocations even more.

akamsteeg commented 4 months ago

Before:

Method Toolchain password Mean Ratio Allocated Alloc Ratio
GetKAnonimityPartsForPassword .NET 6.0 -&HxcB_d 275.7 ns +5% 280 B +0%
GetKAnonimityPartsForPassword .NET 8.0 -&HxcB_d 263.4 ns baseline 280 B
GetKAnonimityPartsForPassword .NET Framework 4.8.1 -&HxcB_d 3,006.0 ns +1,042% 4710 B +1,582%
GetKAnonimityPartsForPassword .NET 6.0 -&Hxc(...)&,#x} [32] 282.1 ns +2% 280 B +0%
GetKAnonimityPartsForPassword .NET 8.0 -&Hxc(...)&,#x} [32] 277.9 ns baseline 280 B
GetKAnonimityPartsForPassword .NET Framework 4.8.1 -&Hxc(...)&,#x} [32] 3,054.7 ns +997% 4734 B +1,591%
GetKAnonimityPartsForPassword .NET 6.0 -&Hxc(...)QbuAz [64] 373.9 ns +2% 280 B +0%
GetKAnonimityPartsForPassword .NET 8.0 -&Hxc(...)QbuAz [64] 365.1 ns baseline 280 B
GetKAnonimityPartsForPassword .NET Framework 4.8.1 -&Hxc(...)QbuAz [64] 3,118.4 ns +754% 4766 B +1,602%

After:

Method Toolchain password Mean Ratio Allocated Alloc Ratio
GetKAnonimityPartsForPassword .NET 6.0 -&HxcB_d 277.7 ns +10% 232 B +0%
GetKAnonimityPartsForPassword .NET 8.0 -&HxcB_d 253.7 ns baseline 232 B
GetKAnonimityPartsForPassword .NET Framework 4.8.1 -&HxcB_d 3,015.2 ns +1,089% 4710 B +1,930%
GetKAnonimityPartsForPassword .NET 6.0 -&Hxc(...)&,#x} [32] 281.6 ns +4% 232 B +0%
GetKAnonimityPartsForPassword .NET 8.0 -&Hxc(...)&,#x} [32] 270.9 ns baseline 232 B
GetKAnonimityPartsForPassword .NET Framework 4.8.1 -&Hxc(...)&,#x} [32] 3,030.7 ns +1,021% 4734 B +1,941%
GetKAnonimityPartsForPassword .NET 6.0 -&Hxc(...)QbuAz [64] 342.2 ns +5% 232 B +0%
GetKAnonimityPartsForPassword .NET 8.0 -&Hxc(...)QbuAz [64] 325.0 ns baseline 232 B
GetKAnonimityPartsForPassword .NET Framework 4.8.1 -&Hxc(...)QbuAz [64] 3,129.8 ns +863% 4766 B +1,954%