Esempio n. 1
0
 extern static void SDK_TestCallDelegate(FTestDelegate func, int num, int repeat, int a, float b);
Esempio n. 2
0
        public static void Benchmark()
        {
            if (DoBenchMark == false)
            {
                return;
            }
            ScopeAll.Begin();
            const int repeat = 1;//1000
            const int count  = 100000;

            FTestDelegate fun = (int num, int a, float b) =>
            {
                int r = 0;
                for (int i = 0; i < num; i++)
                {
                    r += a;
                    r += (int)b;
                }
                return(r);
            };

            ScopeDelegate.Begin();
            for (int i = 0; i < count; i++)
            {
                fun(repeat, 1, 2.0f);
            }
            var t2 = Support.Time.HighPrecision_GetTickCount();

            ScopeDelegate.End();

            ScopeMethod.Begin();
            for (int i = 0; i < count; i++)
            {
                TestCall(repeat, 1, 2.0f);
            }
            t2 = Support.Time.HighPrecision_GetTickCount();
            ScopeMethod.End();

            ScopeCallCpp.Begin();
            for (int i = 0; i < count; i++)
            {
                SDK_TestCall(repeat, 1, 2.0f);
            }
            ScopeCallCpp.End();

            ScopeCpp2Delegate.Begin();
            SDK_TestCallDelegate(fun, count, repeat, 1, 2.0f);
            ScopeCpp2Delegate.End();

            ScopeCppPure.Begin();
            SDK_TestPureCpp(count, repeat, 1, 2.0f);
            ScopeCppPure.End();

            const int samp_count = 10000;

            ScopeTimeScope.Begin();
            ScopeTimeScopeDummy.Enable = true;
            for (int i = 0; i < samp_count; i++)
            {
                ScopeTimeScopeDummy.Begin();
                ScopeTimeScopeDummy.End();
            }
            ScopeTimeScope.End();

            ScopeAll.End();
        }