From 7657f31fd1b2e30e1decf16ec9652c04026609c6 Mon Sep 17 00:00:00 2001 From: Paul Liverman III Date: Wed, 26 Jul 2017 21:00:17 -0700 Subject: [PATCH] better demo --- main.lua | 53 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/main.lua b/main.lua index 1a38811..e31c78c 100644 --- a/main.lua +++ b/main.lua @@ -1,53 +1,62 @@ -Profiler = require("piefiller") -ProfOn = true +profilerOn = true drawRect = true -local Prof = Profiler:new() + +local Profiler = require("piefiller") +local profiler = Profiler:new() + function iterateSmall() for i=1,1000 do end end function iterateLarge() - for i=1,100000 do - + for i=1,1000000 do end end +function iterateHuge() + for i=1,1000000000 do + end +end + function drawRectangles() for i=1,100 do love.graphics.setColor(255,0,0) love.graphics.rectangle("line",i,i,i,i) - love.graphics.setColor(255,255,255) end end -function love.load() -end + function love.draw() if drawRect then drawRectangles() - Prof:detach() end - if ProfOn then - Prof:draw({50}) + + profiler:detach() -- was attached in update function + + if profilerOn then + -- profiler:draw({50}) -- did not appear to have a difference in 0.9.2 or 0.10.2 + profiler:draw() end end + function love.update(dt) - Prof:attach() + profiler:attach() + iterateSmall() iterateLarge() - if drawRect then - Prof:detach(true) - else - Prof:detach() - end - local data = Prof:unpack() + iterateHuge() + + -- detached in draw function end + function love.keypressed(key) - if key == "esc" then - ProfOn = not ProfOn + if key == "escape" then + profilerOn = not profilerOn elseif key == ";" then drawRect = not drawRect end - Prof:keypressed(key) + + profiler:keypressed(key) end + function love.mousepressed(...) - Prof:mousepressed(...) + profiler:mousepressed(...) end