You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 23, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 23, 2026. It is now read-only.
usingSystem;usingSystem.Runtime.InteropServices;usingBenchmarkDotNet.Attributes;usingBenchmarkDotNet.Running;namespacePInvokeBenchmark{publicclassPInvokeBenchmarks{// Define a delegate type for our managed functionprivatedelegateintManagedDelegate(boolvalue);// Define a matching function pointer type for unmanaged callsprivateunsafedelegateintUnmanagedDelegate(boolvalue);// The managed implementationprivatestaticintManagedImplementation(boolvalue){returnvalue?42:0;}// Our instance of the delegateprivatereadonlyManagedDelegate_managedDelegate;// Marshaled function pointerprivatereadonlyunsafedelegate* unmanaged<bool,int>_nativeFunctionPointer;// Delegate wrapping the marshaled function pointerprivatereadonlyunsafedelegate* unmanaged<bool,int>_unmanagedDelegate;// P/Invoke declaration for the native method[DllImport(@"C:\temp\pinvokeBench\NativeDll\NativeDll.dll",CallingConvention=CallingConvention.Cdecl)]privatestaticexternintMethod(boolvalue);publicunsafePInvokeBenchmarks(){// Create the managed delegate_managedDelegate=ManagedImplementation;// Marshal it to a native function pointer_nativeFunctionPointer=(delegate* unmanaged<bool,int>)Marshal.GetFunctionPointerForDelegate(_managedDelegate);}[Benchmark]publicunsafeintMarshaledDelegateCall(){return_nativeFunctionPointer(true);}}}
Activity
EgorBot commentedon Jul 9, 2025
Benchmark results on
linux_azure_cobalt100BDN_Artifacts.zip
cc @davidwrighton (agent_logs.txt). EgorBot manual: link.