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

EgorBot for EgorBo in #50915 #58

Open
EgorBot opened this issue Sep 3, 2024 · 3 comments
Open

EgorBot for EgorBo in #50915 #58

EgorBot opened this issue Sep 3, 2024 · 3 comments

Comments

@EgorBot
Copy link
Owner

EgorBot commented Sep 3, 2024

Processing dotnet/runtime#50915 (comment) command:

Command

-intel -arm64 --runtimes net6.0 net7.0 net8.0 net9.0

using BenchmarkDotNet.Attributes;

[MemoryDiagnoser]
[DisassemblyDiagnoser]
public class Bench
{
    private S _s = default(S);
    private C _c = new C();
    private S? _ns = (S?)default(S);

    [Benchmark] public int Struct() => CallM(_s);
    [Benchmark] public int Class() => CallM(_c);
    [Benchmark] public int Nullable() => CallM(_ns);
    [Benchmark] public int NullableSpecialized() => CallMSpecial(_ns);

    static int CallM<T>(T t)
    {
        if (t is IMyInterface)
        {
            return ((IMyInterface)t).M();
        }

        return 0;
    }

    static int CallMSpecial<T>(T? t) where T : struct
    {
        if (t.HasValue)
        {
            return CallM(t.GetValueOrDefault());
        }

        return 0;
    }
}

interface IMyInterface
{
    int M();
}

struct S : IMyInterface
{
    public int M() => 42;
}

class C : IMyInterface
{
    public int M() => 42;
}

(EgorBot will reply in this issue)

@EgorBot
Copy link
Owner Author

EgorBot commented Sep 3, 2024

❌ Failed on Intel: Benchmark run failed

cc @EgorBo (logs)

@EgorBot
Copy link
Owner Author

EgorBot commented Sep 3, 2024

Benchmark results on Ampere

BenchmarkDotNet v0.14.0, Ubuntu 22.04.4 LTS (Jammy Jellyfish)
Ampere
  Job-AOJGNR : .NET 6.0.33 (6.0.3324.36610), Arm64 RyuJIT AdvSIMD
  Job-BHTBPA : .NET 7.0.20 (7.0.2024.26716), Arm64 RyuJIT AdvSIMD
  Job-CCEICE : .NET 8.0.8 (8.0.824.36612), Arm64 RyuJIT AdvSIMD
  Job-EMWDZB : .NET 9.0.0 (9.0.24.40507), Arm64 RyuJIT AdvSIMD
Method Runtime Mean Error Ratio Code Size Gen0 Allocated Alloc Ratio
Struct .NET 6.0 2.2353 ns 0.0001 ns 1.00 40 B - - NA
Struct .NET 7.0 2.0153 ns 0.0003 ns 0.90 56 B - - NA
Struct .NET 8.0 1.4509 ns 0.0003 ns 0.65 56 B - - NA
Struct .NET 9.0 1.3027 ns 0.0003 ns 0.58 36 B - - NA
Class .NET 6.0 6.8528 ns 0.0691 ns 1.00 132 B - - NA
Class .NET 7.0 4.6914 ns 0.0018 ns 0.68 152 B - - NA
Class .NET 8.0 5.2436 ns 0.0006 ns 0.77 192 B - - NA
Class .NET 9.0 2.4029 ns 0.0008 ns 0.35 48 B - - NA
Nullable .NET 6.0 92.8404 ns 0.2149 ns 1.00 120 B 0.0014 24 B 1.00
Nullable .NET 7.0 84.8922 ns 0.1184 ns 0.91 152 B 0.0014 24 B 1.00
Nullable .NET 8.0 81.9274 ns 0.0945 ns 0.88 184 B 0.0014 24 B 1.00
Nullable .NET 9.0 70.1827 ns 0.0487 ns 0.76 36 B 0.0014 24 B 1.00
NullableSpecialized .NET 6.0 2.1223 ns 0.0012 ns 1.00 76 B - - NA
NullableSpecialized .NET 7.0 2.1239 ns 0.0006 ns 1.00 84 B - - NA
NullableSpecialized .NET 8.0 0.9391 ns 0.0003 ns 0.44 80 B - - NA
NullableSpecialized .NET 9.0 1.1526 ns 0.0008 ns 0.54 60 B - - NA

BDN_Artifacts.zip

@EgorBot
Copy link
Owner Author

EgorBot commented Sep 3, 2024

cc @EgorBo (logs)

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

No branches or pull requests

1 participant