2017-07-27 02:41:07 +00:00
|
|
|
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()
|
2017-07-27 02:41:07 +00:00
|
|
|
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
|
2017-07-27 02:41:07 +00:00
|
|
|
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()
|
2017-07-27 02:41:07 +00:00
|
|
|
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)
|
2017-07-27 02:41:07 +00:00
|
|
|
end
|
|
|
|
end
|
2017-07-27 04:00:17 +00:00
|
|
|
|
2015-11-07 11:24:53 +00:00
|
|
|
function love.draw()
|
2017-07-27 02:41:07 +00:00
|
|
|
if drawRect then
|
2015-11-07 11:24:53 +00:00
|
|
|
drawRectangles()
|
2017-07-27 02:41:07 +00:00
|
|
|
end
|
2017-07-27 04:00:17 +00:00
|
|
|
|
|
|
|
profiler:detach() -- was attached in update function
|
|
|
|
|
2017-07-27 05:35:13 +00:00
|
|
|
-- temporary
|
|
|
|
local w, h = love.graphics.getWidth(), love.graphics.getHeight()
|
|
|
|
love.graphics.setColor(255, 255, 255, 255)
|
|
|
|
love.graphics.rectangle("fill", 0, 0, w, h)
|
|
|
|
|
2017-07-27 05:15:35 +00:00
|
|
|
profiler:draw()
|
2017-07-27 05:35:13 +00:00
|
|
|
|
|
|
|
-- temporary
|
|
|
|
love.graphics.line(w/2, 0, w/2, h)
|
|
|
|
love.graphics.line(0, h/2, w, h/2)
|
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()
|
2017-07-27 02:41:07 +00:00
|
|
|
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
|