Skip to content
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

Fix regression in Number.NumberBuffer.cs #102950

Merged
merged 1 commit into from
Jun 1, 2024
Merged

Conversation

hamarb123
Copy link
Contributor

Fixes #102865

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jun 1, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-numerics
See info in area-owners.md if you want to be subscribed.

@hamarb123
Copy link
Contributor Author

@EgorBot -arm64 -intel -mono

using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;

namespace System.Tests
{
    public class Perf_Double
    {
        public static IEnumerable<object> Values => new object[]
        {
            double.MinValue,
            12345.0 /* same value used by other tests to compare the perf */,
            double.MaxValue
        };

        public static IEnumerable<object> StringValues
            // r is used to fromat Min and Max values to a parsable string https://stackoverflow.com/a/767011
            => Values.OfType<double>().Select(value => value.ToString("r")).ToArray();

        [Benchmark]
        [ArgumentsSource(nameof(StringValues))]
        [MemoryRandomization]
        public double Parse(string value) => double.Parse(value);

        [Benchmark]
        [ArgumentsSource(nameof(StringValues))]
        [MemoryRandomization]
        public bool TryParse(string value) => double.TryParse(value, out _);
    }
}

@EgorBot
Copy link

EgorBot commented Jun 1, 2024

Benchmark results on Intel
BenchmarkDotNet v0.13.12, Ubuntu 22.04.4 LTS (Jammy Jellyfish)
Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 8 logical and 4 physical cores
  Job-RDNTPH : .NET 9.0.0 (42.42.42.42424) using MonoVM, X64 X86Base
  Job-LLGMLJ : .NET 9.0.0 (42.42.42.42424) using MonoVM, X64 X86Base
OutlierMode=DontRemove  MemoryRandomization=True
Method Toolchain value Mean Error Ratio
Parse Main -1.79(...)e+308 [24] 433.9 ns 2.64 ns 1.00
Parse PR -1.79(...)e+308 [24] 273.2 ns 0.43 ns 0.63
TryParse Main -1.79(...)e+308 [24] 428.2 ns 1.43 ns 1.00
TryParse PR -1.79(...)e+308 [24] 275.0 ns 0.18 ns 0.64
Parse Main 1.797(...)e+308 [23] 435.3 ns 1.86 ns 1.00
Parse PR 1.797(...)e+308 [23] 265.1 ns 0.65 ns 0.61
TryParse Main 1.797(...)e+308 [23] 423.7 ns 1.03 ns 1.00
TryParse PR 1.797(...)e+308 [23] 270.6 ns 0.56 ns 0.64
Parse Main 12345 230.8 ns 0.75 ns 1.00
Parse PR 12345 170.4 ns 0.34 ns 0.74
TryParse Main 12345 228.8 ns 1.13 ns 1.00
TryParse PR 12345 166.1 ns 0.61 ns 0.73

BDN_Artifacts.zip

@EgorBot
Copy link

EgorBot commented Jun 1, 2024

Benchmark results on Arm64
BenchmarkDotNet v0.13.12, Ubuntu 22.04.4 LTS (Jammy Jellyfish)
Unknown processor
  Job-OUOATG : .NET 9.0.0 (42.42.42.42424) using MonoVM, Arm64 ArmBase
  Job-ZVFUPP : .NET 9.0.0 (42.42.42.42424) using MonoVM, Arm64 ArmBase
OutlierMode=DontRemove  MemoryRandomization=True
Method Toolchain value Mean Error Ratio
Parse Main -1.79(...)e+308 [24] 592.0 ns 2.66 ns 1.00
Parse PR -1.79(...)e+308 [24] 452.2 ns 1.56 ns 0.76
TryParse Main -1.79(...)e+308 [24] 564.8 ns 1.20 ns 1.00
TryParse PR -1.79(...)e+308 [24] 437.5 ns 2.26 ns 0.77
Parse Main 1.797(...)e+308 [23] 579.6 ns 1.67 ns 1.00
Parse PR 1.797(...)e+308 [23] 444.3 ns 3.52 ns 0.77
TryParse Main 1.797(...)e+308 [23] 556.1 ns 1.87 ns 1.00
TryParse PR 1.797(...)e+308 [23] 431.1 ns 2.12 ns 0.78
Parse Main 12345 362.2 ns 0.68 ns 1.00
Parse PR 12345 283.4 ns 0.54 ns 0.78
TryParse Main 12345 340.4 ns 0.71 ns 1.00
TryParse PR 12345 275.7 ns 0.94 ns 0.81

BDN_Artifacts.zip

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@jkotas jkotas merged commit 961dfae into dotnet:main Jun 1, 2024
81 of 83 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jul 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Numerics community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Perf_Single/Double.TryParse regressions
3 participants