uruk-project / Jwt

JSON Web Token implementation for .Net & .Net Core
MIT License
81 stars 13 forks source link

Add benchmark for initilizing an array of 32 & 64 bytes #487

Closed ycrumeyrolle closed 3 years ago

codecov[bot] commented 3 years ago

Codecov Report

Merging #487 into master will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #487   +/-   ##
=======================================
  Coverage   63.00%   63.00%           
=======================================
  Files         165      165           
  Lines        8771     8771           
  Branches     1448     1448           
=======================================
  Hits         5526     5526           
  Misses       2723     2723           
  Partials      522      522           
Impacted Files Coverage Δ
src/JsonWebToken/Cryptography/Sha256.cs 96.00% <100.00%> (ø)
src/JsonWebToken/Cryptography/Sha384.cs 75.24% <100.00%> (ø)
src/JsonWebToken/Cryptography/Sha512.cs 93.14% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 7a13c62...ae98640. Read the comment docs.

ycrumeyrolle commented 3 years ago

The main benefit of the Unsafe.CopyBlock come from the jitter that is able to identify a constant sized byte array and to vectorize the copy.

Method Mean Error StdDev Ratio RatioSD Code Size
InitUint32_Original 2.6049 ns 0.0357 ns 0.0316 ns 1.00 0.00 128 B
InitUint32_UnsafeCopyBlock 0.7034 ns 0.0538 ns 0.0681 ns 0.27 0.03 104 B
InitUint32_UnsafeCopyBlockUnaligned 1.0163 ns 0.0522 ns 0.0536 ns 0.39 0.02 104 B
InitUint32_SpanCopyTo 3.4210 ns 0.0961 ns 0.1107 ns 1.32 0.04 426 B
InitUint64_Original 4.0400 ns 0.1044 ns 0.1025 ns 1.55 0.04 185 B
InitUint64_UnsafeCopyBlockUnaligned 2.9553 ns 0.0524 ns 0.0409 ns 1.13 0.01 125 B
InitUint64_UnsafeCopyBlock 2.9520 ns 0.0556 ns 0.0492 ns 1.13 0.02 125 B
InitUint64_SpanCopyTo 5.3443 ns 0.1144 ns 0.1405 ns 2.06 0.06 436 B