I have two library, first one is the original which was done in vb.net, second one is in c#.
doing exactly the same thing.
vb.net is about 10% faster than c# which is very strange
so what I have found that seem the cause of the slowdown, by looking at IL
code of both is(i would say that close to 99% of the il
code is the same);
in c# all method call have
hidebysig
but not in vb.netis this one thing that could be a performance issue?
in c# you must initialize a local variable before using it
this wont work in c#
void test() { int a; a += 1; }
this will
void test() { int a = 0; a += 1; }
while this work in vb.net
Sub test() Dim a As Integer a += 1 End Sub
which in c# cause 2 more IL line which, I'm pretty sure, cause a performance issue
in vb.net it seem I cannot get the
il
code to usecall
, it always usecallvirt
while c# always usecall
is this one thing that could be a performance issue?
.maxstack is sometime bigger in c#
is this one thing that could be a performance issue?
in the end, I'm trying to understand how to get back that 10% speed loss. So far I'm clueless
if you want to take a look here it is, you can decompile it yourself, i used ilspy;
ZIP file, compiled version
ChessEngine.dll
ChessEngineSharp.dll
ConsoleApplication1.exe