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
publicclassBenchmarkNatives{[NativeMethod]publicvirtualvoidCallRemoteFunction(stringfunc,stringformat,paramsobject[]args){thrownewNativeNotImplementedException();}}publicclassGameMode:BaseMode{private(string,int,float)?_benchStore;protectedoverridevoidOnInitialized(EventArgse){base.OnInitialized(e);// (...)Console.WriteLine("Bench start");RunCallbackBenchmark();}privatevoidRunCallbackBenchmark(){varnatives=NativeObjectProxyFactory.CreateInstance<BenchmarkNatives>();varargs=newobject[]{"stringValue",4321,23.665f};varsw=newStopwatch();constintmaxRuns=10;constintrunCallCount=1_000_000;vartotalElapsed=TimeSpan.Zero;for(varj=0;j<=maxRuns;j++){Console.WriteLine($"Bench run {j}/{maxRuns}");if(j==0)Console.WriteLine("(warmup)");sw.Restart();for(vari=0;i<runCallCount;i++){natives.CallRemoteFunction("BenchmarkCallback","sdf",args);// validateif(!_benchStore.HasValue||_benchStore.Value.Item1!="stringValue"||_benchStore.Value.Item2!=4321||Math.Abs(_benchStore.Value.Item3-23.665f)>0.001f){thrownewInvalidOperationException("native call failed!");}_benchStore=null;}sw.Stop();if(j>0)totalElapsed+=sw.Elapsed;Console.WriteLine($"{runCallCount} calls took {sw.Elapsed}");}Console.WriteLine($"AVG of {totalElapsed/maxRuns}");}[Callback]publicvoidBenchmarkCallback(stringstringValue,intintValue,floatfloatValue){_benchStore=(stringValue,intValue,floatValue);}}
Activity
ikkentim commentedon Mar 30, 2022
a538257 performance. compiled plugin and .net libraries in release mode:
ikkentim commentedon Mar 31, 2022
changed benchmark to perform 1_000_000 instead of 100_000 in 9649ad6
benchmark times are:
ikkentim commentedon Mar 31, 2022
[UnmanagedOnlyAttribute]entrypoints for ticks and public calls1179c63
benchmark times are:
So that looks like a (1 - 150 ÷ 205 =) ~27% performance improvement already
ikkentim commentedon Apr 2, 2022
Also tested this on an Ubuntu VM @ 4a55771
When tested on master branch @ 9649ad6
So that also looks like a (1 - 1,78344 / 2,5548 =) ~30% performance improvement
ikkentim commentedon Apr 8, 2022
Good enough for now, merged.