OPCFoundation / UA-.NETStandard

OPC Unified Architecture .NET Standard
Other
1.9k stars 926 forks source link

Improve JsonEncoder.WriteDateTime #2514

Closed mregen closed 4 months ago

mregen commented 4 months ago

Proposed changes


BenchmarkDotNet v0.13.12, Windows 11 (10.0.22000.2652/21H2/SunValley)
Intel Core i9-10885H CPU 2.40GHz, 1 CPU, 16 logical and 8 physical cores
  [Host]     : .NET Framework 4.8.1 (4.8.9195.0), X64 RyuJIT VectorSize=256
  Job-FYOECP : .NET 6.0.26 (6.0.2623.60508), X64 RyuJIT AVX2
  Job-ACBKDI : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2
  Job-XTPWQX : .NET Framework 4.8.1 (4.8.9195.0), X64 RyuJIT VectorSize=256
Method Runtime OmittedZeros Mean Error StdDev Median Ratio RatioSD Gen0 Code Size Allocated Alloc Ratio
DateTimeEncodeToString .NET 6.0 0 774.14 ns 41.641 ns 122.780 ns 740.98 ns 0.73 0.16 0.0095 707 B 80 B 0.22
DateTimeEncodeToString .NET 8.0 0 402.21 ns 15.714 ns 45.837 ns 395.37 ns 0.38 0.05 0.0095 1,738 B 80 B 0.22
DateTimeEncodeToString .NET Framework 4.8 0 1,082.08 ns 44.020 ns 128.409 ns 1,047.75 ns 1.00 0.00 0.0572 479 B 369 B 1.00
ConvertToUniversalTime .NET 6.0 0 83.37 ns 3.494 ns 9.968 ns 82.00 ns 0.23 0.04 0.0095 280 B 80 B 0.91
ConvertToUniversalTime .NET 8.0 0 59.51 ns 1.679 ns 4.924 ns 58.37 ns 0.16 0.02 0.0095 1,578 B 80 B 0.91
ConvertToUniversalTime .NET Framework 4.8 0 364.16 ns 10.851 ns 31.308 ns 352.88 ns 1.00 0.00 0.0138 149 B 88 B 1.00
DateTimeEncodeToString .NET 6.0 4 492.33 ns 15.977 ns 46.606 ns 481.02 ns 0.45 0.07 0.0086 707 B 72 B 0.20
DateTimeEncodeToString .NET 8.0 4 347.51 ns 9.949 ns 27.898 ns 340.83 ns 0.31 0.04 0.0086 1,738 B 72 B 0.20
DateTimeEncodeToString .NET Framework 4.8 4 1,124.20 ns 47.988 ns 139.982 ns 1,089.04 ns 1.00 0.00 0.0553 479 B 353 B 1.00
ConvertToUniversalTime .NET 6.0 4 92.98 ns 2.617 ns 7.510 ns 90.97 ns 0.22 0.03 0.0181 280 B 152 B 0.90
ConvertToUniversalTime .NET 8.0 4 80.22 ns 2.779 ns 7.928 ns 77.55 ns 0.19 0.03 0.0181 1,870 B 152 B 0.90
ConvertToUniversalTime .NET Framework 4.8 4 434.21 ns 16.813 ns 49.045 ns 422.54 ns 1.00 0.00 0.0267 149 B 168 B 1.00
DateTimeEncodeToString .NET 6.0 7 462.28 ns 11.506 ns 33.014 ns 458.98 ns 0.52 0.05 0.0076 707 B 64 B 0.20
DateTimeEncodeToString .NET 8.0 7 271.40 ns 7.663 ns 22.109 ns 268.63 ns 0.30 0.04 0.0076 1,816 B 64 B 0.20
DateTimeEncodeToString .NET Framework 4.8 7 897.91 ns 24.849 ns 70.896 ns 888.67 ns 1.00 0.00 0.0496 479 B 313 B 1.00
ConvertToUniversalTime .NET 6.0 7 119.99 ns 5.272 ns 15.462 ns 118.03 ns 0.30 0.05 0.0172 280 B 144 B 0.90
ConvertToUniversalTime .NET 8.0 7 85.46 ns 3.500 ns 10.209 ns 83.34 ns 0.21 0.03 0.0172 1,870 B 144 B 0.90
ConvertToUniversalTime .NET Framework 4.8 7 404.68 ns 13.675 ns 39.890 ns 399.14 ns 1.00 0.00 0.0253 149 B 160 B 1.00

Related Issues

Types of changes

What types of changes does your code introduce? Put an x in the boxes that apply. You can also fill these out after creating the PR.

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

mregen commented 4 months ago

test case coverage in the unit test looks quite comprehensive to me, so we should be good.

codecov didn't post a comment. Need to check why not.