Example #1
0
        public static void SetMainLuaEnv(LuaState env)
        {
            if (LuaDeepProfilerSetting.Instance.isDeepProfiler)
            {
                if (env != null)
                {
                    env.BeginModule(null);
                    env.BeginModule("MikuLuaProfiler");
                    MikuLuaProfiler_LuaProfilerWrap.Register(env);
                    env.EndModule();
                    env.EndModule();
                    env.DoString(@"
BeginMikuSample = MikuLuaProfiler.LuaProfiler.BeginSample
EndMikuSample = MikuLuaProfiler.LuaProfiler.EndSample

function miku_unpack_return_value(...)
	EndMikuSample()
	return ...
end
");
                    HookSetup.HookLuaFuns();
                }
            }

            if (env == null)
            {
                HookSetup.Uninstall();
                LuaProfiler.mainL = IntPtr.Zero;
            }
        }
        public static void BeginSample(IntPtr luaState, string name)
        {
            if (m_currentFrame != Time.frameCount)
            {
                PopAllSampleWhenLateUpdate();
                m_currentFrame = Time.frameCount;
            }
#if UNITY_EDITOR
            HookSetup.HookLuaFuns();
#endif

#if DEBUG
            if (beginSampleMemoryStack.Count == 0 && _stableGC)
            {
                LuaLib.lua_gc(luaState, LuaGCOptions.LUA_GCSTOP, 0);
            }

            long   memoryCount = GetLuaMemory(luaState);
            Sample sample      = Sample.Create(Time.realtimeSinceStartup, memoryCount, name);

            beginSampleMemoryStack.Add(sample);
            if (!isDeep)
            {
                Profiler.BeginSample(name);
            }
#endif
        }
Example #3
0
 public static void lua_close(IntPtr luaState)
 {
     if (LuaProfiler.mainL == luaState)
     {
         LuaProfiler.mainL = IntPtr.Zero;
         HookSetup.Uninstall();
     }
 }
Example #4
0
 public static void Start(LuaState env)
 {
     Proxy(env);
     HookSetup.SetMainLuaEnv(env);
 }