Piefiller/main.lua

55 lines
801 B
Lua
Raw Normal View History

drawRect = true
2017-07-27 04:00:17 +00:00
local Profiler = require("piefiller")
2017-07-27 05:15:35 +00:00
local profiler = Profiler()
2017-07-27 04:00:17 +00:00
2015-11-07 11:24:53 +00:00
function iterateSmall()
for i=1,1000 do
end
2015-11-07 11:24:53 +00:00
end
function iterateLarge()
2017-07-27 04:00:17 +00:00
for i=1,1000000 do
end
end
function iterateHuge()
for i=1,1000000000 do
end
2015-11-07 11:24:53 +00:00
end
2017-07-27 04:00:17 +00:00
2015-11-07 11:24:53 +00:00
function drawRectangles()
for i=1,100 do
2015-11-07 11:24:53 +00:00
love.graphics.setColor(255,0,0)
love.graphics.rectangle("line",i,i,i,i)
end
end
2017-07-27 04:00:17 +00:00
2015-11-07 11:24:53 +00:00
function love.draw()
if drawRect then
2015-11-07 11:24:53 +00:00
drawRectangles()
end
2017-07-27 04:00:17 +00:00
profiler:detach() -- was attached in update function
2017-07-27 05:15:35 +00:00
profiler:draw()
2015-11-07 11:24:53 +00:00
end
2017-07-27 04:00:17 +00:00
2015-11-07 11:24:53 +00:00
function love.update(dt)
2017-07-27 04:00:17 +00:00
profiler:attach()
2015-11-07 11:24:53 +00:00
iterateSmall()
iterateLarge()
2017-07-27 04:00:17 +00:00
iterateHuge()
-- detached in draw function
2015-11-07 11:24:53 +00:00
end
2017-07-27 04:00:17 +00:00
2015-11-07 11:24:53 +00:00
function love.keypressed(key)
2017-07-27 04:00:17 +00:00
if key == "escape" then
2017-07-27 05:15:35 +00:00
love.event.quit()
elseif key == ";" then
drawRect = not drawRect
end
2017-07-27 04:00:17 +00:00
profiler:keypressed(key)
2015-11-07 11:24:53 +00:00
end