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

adding net48 to the benchmark project targets #57

Merged
merged 1 commit into from
May 4, 2024

Conversation

lipchev
Copy link
Contributor

@lipchev lipchev commented May 4, 2024

  • updating the FromString benchmarks (multi-target)
  • updating the results for FromString and BasicMath (multi-target)

I've got some very interesting charts, please merge this before the PR for #56 so that it would be easier to compare (I've got the same set of results there as well).

.. more info to come

- updating the FromString benchmarks (multi-target)
- updating the results for FromString and BasicMath (multi-target)
@danm-de danm-de merged commit d8e9eb7 into danm-de:master May 4, 2024
1 check passed
@lipchev
Copy link
Contributor Author

lipchev commented May 4, 2024

Have a look at the difference between simply parsing a string as BigInteger


[MemoryDiagnoser]
[ShortRunJob(RuntimeMoniker.Net48)]
[ShortRunJob(RuntimeMoniker.Net80)]
public class BigIntegerBenchmarks {

    [Benchmark(Baseline = true)]
    public BigInteger Parsing_12345_with_sign() {
        return BigInteger.Parse("-12345789987654321", NumberStyles.AllowLeadingSign);
    }

    [Benchmark]
    public BigInteger Parsing_12345_and_negate() {
        return -BigInteger.Parse("12345789987654321", NumberStyles.None);
    }
    
    [Benchmark]
    public BigInteger Parsing_12345_as_integer() {
        return BigInteger.Parse("-12345789987654321", NumberStyles.Integer);
    }
    
    [Benchmark]
    public BigInteger Parsing_12345_as_number() {
        return BigInteger.Parse("-12345789987654321", NumberStyles.Number);
    }
    
    [Benchmark]
    public BigInteger Parsing_12345_as_any() {
        return BigInteger.Parse("-12345789987654321", NumberStyles.Any);
    }

    [Benchmark]
    public BigInteger Parsing_0_12345_with_sign() {
        return BigInteger.Parse("-0000000000000000000012345789987654321", NumberStyles.AllowLeadingSign);
    }

    [Benchmark]
    public BigInteger Parsing_0_12345_and_negate() {
        return -BigInteger.Parse("0000000000000000000012345789987654321", NumberStyles.None);
    }

    [Benchmark]
    public BigInteger Parsing_0_12345_as_integer() {
        return BigInteger.Parse("-0000000000000000000012345789987654321", NumberStyles.Integer);
    }
    
    [Benchmark]
    public BigInteger Parsing_0_12345_as_number() {
        return BigInteger.Parse("-0000000000000000000012345789987654321", NumberStyles.Number);
    }
    
    [Benchmark]
    public BigInteger Parsing_0_12345_as_any() {
        return BigInteger.Parse("-0000000000000000000012345789987654321", NumberStyles.Any);
    }
}
BenchmarkDotNet v0.13.12, Windows 10 (10.0.19045.4291/22H2/2022Update)
AMD Ryzen 9 7900X, 1 CPU, 24 logical and 12 physical cores
.NET SDK 8.0.204
  [Host]                      : .NET 8.0.4 (8.0.424.16909), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
  ShortRun-.NET 8.0           : .NET 8.0.4 (8.0.424.16909), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
  ShortRun-.NET Framework 4.8 : .NET Framework 4.8.1 (4.8.9232.0), X64 RyuJIT VectorSize=256

IterationCount=3 LaunchCount=1 WarmupCount=3

Method Job Runtime Mean Error StdDev Ratio RatioSD Gen0 Allocated Alloc Ratio
Parsing_12345_with_sign ShortRun-.NET 8.0 .NET 8.0 100.59 ns 5.574 ns 0.306 ns 1.00 0.00 0.0143 240 B 1.00
Parsing_12345_and_negate ShortRun-.NET 8.0 .NET 8.0 88.97 ns 15.474 ns 0.848 ns 0.88 0.01 0.0143 240 B 1.00
Parsing_12345_as_integer ShortRun-.NET 8.0 .NET 8.0 99.17 ns 9.046 ns 0.496 ns 0.99 0.01 0.0143 240 B 1.00
Parsing_12345_as_number ShortRun-.NET 8.0 .NET 8.0 89.47 ns 6.645 ns 0.364 ns 0.89 0.00 0.0143 240 B 1.00
Parsing_12345_as_any ShortRun-.NET 8.0 .NET 8.0 100.88 ns 18.144 ns 0.995 ns 1.00 0.01 0.0143 240 B 1.00
Parsing_0_12345_with_sign ShortRun-.NET 8.0 .NET 8.0 134.61 ns 22.490 ns 1.233 ns 1.34 0.01 0.0143 240 B 1.00
Parsing_0_12345_and_negate ShortRun-.NET 8.0 .NET 8.0 125.96 ns 38.847 ns 2.129 ns 1.25 0.02 0.0143 240 B 1.00
Parsing_0_12345_as_integer ShortRun-.NET 8.0 .NET 8.0 140.12 ns 37.378 ns 2.049 ns 1.39 0.02 0.0143 240 B 1.00
Parsing_0_12345_as_number ShortRun-.NET 8.0 .NET 8.0 137.54 ns 16.836 ns 0.923 ns 1.37 0.01 0.0143 240 B 1.00
Parsing_0_12345_as_any ShortRun-.NET 8.0 .NET 8.0 138.55 ns 17.770 ns 0.974 ns 1.38 0.01 0.0143 240 B 1.00
                     
Parsing_12345_with_sign ShortRun-.NET Framework 4.8 .NET Framework 4.8 980.73 ns 139.349 ns 7.638 ns 1.00 0.00 0.1106 706 B 1.00
Parsing_12345_and_negate ShortRun-.NET Framework 4.8 .NET Framework 4.8 999.74 ns 127.631 ns 6.996 ns 1.02 0.02 0.1106 706 B 1.00
Parsing_12345_as_integer ShortRun-.NET Framework 4.8 .NET Framework 4.8 992.41 ns 98.195 ns 5.382 ns 1.01 0.00 0.1106 706 B 1.00
Parsing_12345_as_number ShortRun-.NET Framework 4.8 .NET Framework 4.8 989.30 ns 118.202 ns 6.479 ns 1.01 0.00 0.1106 706 B 1.00
Parsing_12345_as_any ShortRun-.NET Framework 4.8 .NET Framework 4.8 1,012.72 ns 83.545 ns 4.579 ns 1.03 0.01 0.1106 706 B 1.00
Parsing_0_12345_with_sign ShortRun-.NET Framework 4.8 .NET Framework 4.8 1,020.56 ns 34.931 ns 1.915 ns 1.04 0.01 0.1106 706 B 1.00
Parsing_0_12345_and_negate ShortRun-.NET Framework 4.8 .NET Framework 4.8 1,024.28 ns 94.638 ns 5.187 ns 1.04 0.01 0.1106 706 B 1.00
Parsing_0_12345_as_integer ShortRun-.NET Framework 4.8 .NET Framework 4.8 1,016.82 ns 58.949 ns 3.231 ns 1.04 0.01 0.1106 706 B 1.00
Parsing_0_12345_as_number ShortRun-.NET Framework 4.8 .NET Framework 4.8 1,016.81 ns 46.941 ns 2.573 ns 1.04 0.01 0.1106 706 B 1.00
Parsing_0_12345_as_any ShortRun-.NET Framework 4.8 .NET Framework 4.8 1,025.18 ns 120.029 ns 6.579 ns 1.05 0.01 0.1106 706 B 1.00

I guess upgrading really pays off 😄

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.

2 participants