daily update on 20240403 by nitload youmu
This commit is contained in:
@@ -10,16 +10,33 @@ using Microsoft.Diagnostics.Tracing.Parsers.Clr;
|
||||
|
||||
namespace BenchMark
|
||||
{
|
||||
internal unsafe class Program
|
||||
public static class Program
|
||||
{
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
int[] a = new int[10];
|
||||
IntPtr p = GCHandle.Alloc(a, GCHandleType.Pinned).AddrOfPinnedObject();
|
||||
Console.WriteLine(*(int*)p);
|
||||
var summary = BenchmarkRunner.Run<BenchmarkClass>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[SimpleJob(launchCount: 2, warmupCount: 2, iterationCount: 2)]
|
||||
public unsafe class BenchmarkClass
|
||||
{
|
||||
|
||||
[Benchmark]
|
||||
public void HandleCalc()
|
||||
{
|
||||
int[] array = new int[4];
|
||||
IntPtr ptr = GCHandle.Alloc(array).AddrOfPinnedObject();
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public void MemCalc()
|
||||
{
|
||||
int[] array = new int[4];
|
||||
Memory<int> memory = new Memory<int>(array);
|
||||
void* ptr = memory.Pin().Pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user