Skip to content

Benchmarks for #122167 (EgorBo) #563

@EgorBot

Description

@EgorBot

Processing dotnet/runtime#122167 (comment) command:

Command

-amd -arm

using BenchmarkDotNet.Attributes;

[MemoryDiagnoser]
[DisassemblyDiagnoser]
public class Bench
{
    private Nullable<bool> _null = null;
    private Nullable<bool> _nonnull = true;

    [Benchmark] public object BoxNull() => _null; 

    [Benchmark] public object BoxNonNull() => _nonnull;

    // https://github.com/dotnet/runtime/issues/50915
    private S? _ns = (S?)default(S);
    [Benchmark] public int Issue50915() => CallM(_ns);
    static int CallM<T>(T t)
    {
        if (t is IMyInterface)
            return ((IMyInterface)t).M();
        return 0;
    }
}

interface IMyInterface
{
    int M();
}

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

(EgorBot will reply in this issue)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions