Ejemplo n.º 1
0
        public static void BeginSample(IntPtr luaState, string name)
        {
            if (!IsMainThread)
            {
                return;
            }
            HookLuaSetup.OnStartGame();
            var setting = LuaDeepProfilerSetting.Instance;

            if (setting == null)
            {
                return;
            }

            int frameCount = HookLuaSetup.frameCount;

            if (m_currentFrame != frameCount)
            {
                PopAllSampleWhenLateUpdate(luaState);
                m_currentFrame = frameCount;
            }
            long   memoryCount = LuaLib.GetLuaMemory(luaState);
            Sample sample      = Sample.Create(getcurrentTime, (int)memoryCount, name);

            beginSampleMemoryStack.Push(sample);
        }
        public static void __Register(IntPtr L)
        {
            HookLuaSetup.OnStartGame();
            LuaDLL.lua_newtable(L);
            LuaDLL.lua_pushstring(L, "LuaProfiler");
            LuaDLL.lua_newtable(L);
            LuaDLL.lua_pushstring(L, "BeginSample");

            LuaDLL.lua_pushstdcallcfunction(L, beginSample);
            LuaDLL.lua_rawset(L, -3);

            LuaDLL.lua_pushstring(L, "EndSample");
            LuaDLL.lua_pushstdcallcfunction(L, endSample);
            LuaDLL.lua_rawset(L, -3);

            LuaDLL.lua_rawset(L, -3);
            LuaDLL.lua_setglobal(L, "MikuLuaProfiler");

            LuaDLL.lua_pushstdcallcfunction(L, unpackReturnValue);
            LuaDLL.lua_setglobal(L, "miku_unpack_return_value");

            LuaDLL.lua_pushstdcallcfunction(L, addRefFunInfo);
            LuaDLL.lua_setglobal(L, "miku_add_ref_fun_info");

            LuaDLL.lua_pushstdcallcfunction(L, removeRefFunInfo);
            LuaDLL.lua_setglobal(L, "miku_remove_ref_fun_info");

            LuaDLL.lua_pushstdcallcfunction(L, checkType);
            LuaDLL.lua_setglobal(L, "miku_check_type");

            LuaDLL.lua_pushstdcallcfunction(L, handleError);
            LuaDLL.lua_setglobal(L, "miku_handle_error");

            LuaDLL.lua_newtable(L);
            LuaDLL.lua_setglobal(L, "MikuLuaProfilerStrTb");

            LuaLib.DoString(L, get_ref_string);
            LuaLib.DoString(L, null_script);
            LuaLib.DoString(L, diff_script);
        }