void OnGUI() { if (GUI.Button(new Rect(10, 10, 120, 50), "native")) { UnityEngine.Profiling.Profiler.BeginSample("native"); startTime = Time.realtimeSinceStartup; for (int i = 0; i < TIMES; ++i) { NativeCCore.tst_add(i, TIMES); NativeCCore.tst_sub(i, TIMES); NativeCCore.tst_div(i, TIMES); NativeCCore.tst_mul(i, TIMES); } endTime = Time.realtimeSinceStartup; Printf("native"); UnityEngine.Profiling.Profiler.EndSample(); } if (GUI.Button(new Rect(10, 100, 120, 50), "mono")) { UnityEngine.Profiling.Profiler.BeginSample("mono"); startTime = Time.realtimeSinceStartup; for (int i = 0; i < TIMES; ++i) { cs_add(i, TIMES); cs_sub(i, TIMES); cs_div(i, TIMES); cs_mul(i, TIMES); } endTime = Time.realtimeSinceStartup; Printf("mono"); UnityEngine.Profiling.Profiler.EndSample(); } }
private void CallFunction() { m_ret1 = NativeCCore.tst_add(10, 2); m_ret2 = NativeCCore.tst_sub(10, 2); m_ret3 = NativeCCore.tst_div(10, 2); m_ret4 = NativeCCore.tst_mul(10, 2); Debug.Log("10+2=" + m_ret1); Debug.Log("10-2=" + m_ret2); Debug.Log("10/2=" + m_ret3); Debug.Log("10*2=" + m_ret4); }