Skip to content

EgorBot for jkotas in #111088 #223

Open
@EgorBot

Description

@EgorBot

Processing dotnet/runtime#111088 (comment) command:

Command

-windows_intel

using System;
using System.Reflection;
using System.Reflection.Emit;
using BenchmarkDotNet.Attributes;

public class Bench
{
    Func<RuntimeMethodHandle> d = Init();

    static Func<RuntimeMethodHandle> Init()
    {
        DynamicMethod dm = new DynamicMethod("My", typeof(RuntimeMethodHandle), null, typeof(string).Module);

        MethodInfo randomMethod = typeof(object).GetMethod("ReferenceEquals");

        ILGenerator il = dm.GetILGenerator();
        il.Emit(OpCodes.Ldtoken, randomMethod);
        il.Emit(OpCodes.Ret);

        return dm.CreateDelegate<Func<RuntimeMethodHandle>>();
    }

    [Benchmark]
    public RuntimeMethodHandle LdToken() => d();
}

(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