daily update on 20240207 by nitload youmu

This commit is contained in:
Nitload
2024-02-07 13:47:12 +08:00
parent 8548757bbf
commit 6fe6b3b3cf
37 changed files with 231 additions and 196 deletions
+8 -24
View File
@@ -14,32 +14,16 @@ namespace BenchMark
static void Main(string[] args)
{
Calculator c = new Calculator();
c.PtrSub();
var sum = BenchmarkRunner.Run(typeof(Calculator).Assembly);
uint[] array = new uint[] { 0, 10, 2, 3 };
fixed (uint* ptr = array)
{
IntPtr p = (IntPtr)ptr;
Console.WriteLine(*((uint*)p + 1));
}
}
}
public struct Calculator
{
public static int Sub(int left, int right)
{
return left - right;
}
[Benchmark]
public unsafe void DeleSub()
{
Func<int, int, int> SubDele = Sub;
SubDele(1, 0);
}
[Benchmark]
public unsafe void PtrSub()
{
delegate*<int, int, int> SubPtr = &Sub;
SubPtr(1, 0);
}
}
}