From 9336534566dc351e47841b9357536f473ef559d6 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sat, 24 Oct 2020 20:07:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9profile=E5=BC=80=E5=90=AF?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=EF=BC=8C=E5=92=8C=E8=AE=A1=E7=AE=97=E5=99=A8?= =?UTF-8?q?=E7=BB=84=E5=90=88=E5=8A=9F=E8=83=BD=E9=94=AE=E4=B8=8D=E5=86=B2?= =?UTF-8?q?=E7=AA=81=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/init.lua | 23 ++++++----------------- Zframework/profile.lua | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Zframework/init.lua b/Zframework/init.lua index 4f7a140f..a13c1fb5 100644 --- a/Zframework/init.lua +++ b/Zframework/init.lua @@ -191,27 +191,16 @@ end function love.keypressed(i) mouseShow=false if devMode then - if i=="1"then - print("profile start!") - PROFILE.start() - elseif i=="2"then - print("profile stop!") - PROFILE.stop() - elseif i=="3"then - print("profile report copied!") - love.system.setClipboardText(PROFILE.report()) - elseif i=="4"then - print("profile resetted!") - PROFILE.reset() - elseif i=="f1"then - local r=rnd()<.5 - love._setGammaCorrect(r) - LOG.print("GammaCorrect: "..(r and"on"or"off"),"warn") + if i=="f1"then + PROFILE.switch() elseif i=="f2"then LOG.print("System:"..SYSTEM.."["..jit.arch.."]") LOG.print("luaVer:".._VERSION) LOG.print("jitVer:"..jit.version) LOG.print("jitVerNum:"..jit.version_num) + local r=rnd()<.5 + love._setGammaCorrect(r) + LOG.print("GammaCorrect: "..(r and"on"or"off"),"warn") elseif i=="f3"then for _=1,8 do local P=PLAYERS.alive[rnd(#PLAYERS.alive)] @@ -220,7 +209,7 @@ function love.keypressed(i) P:lose() end end - elseif i=="f4"then LOG.copy() + elseif i=="f4"then if not kb.isDown("lalt","ralt")then LOG.copy()end elseif i=="f5"then if love._openConsole then love._openConsole()end elseif i=="f6"then if WIDGET.sel then DBP(WIDGET.sel)end elseif i=="f7"then for k,v in next,_G do DBP(k,v)end diff --git a/Zframework/profile.lua b/Zframework/profile.lua index f08bbcd8..ca1bba63 100644 --- a/Zframework/profile.lua +++ b/Zframework/profile.lua @@ -166,6 +166,20 @@ function profile.report(n) return '\n'..sz..row end +local switch=false +function profile.switch() + if switch then + profile.stop() + love.system.setClipboardText(PROFILE.report()) + PROFILE.reset() + LOG.print("profile report copied!") + else + PROFILE.start() + LOG.print("profile start!") + end + switch=not switch +end + -- store all internal profiler functions for _, v in next,profile do if type(v) == "function" then