2015-11-07 11:24:53 +00:00
|
|
|
Profiler = require("piefiller")
|
|
|
|
ProfOn = true
|
|
|
|
drawRect = true
|
|
|
|
local Prof = Profiler:new()
|
|
|
|
function iterateSmall()
|
|
|
|
for i=1,1000 do
|
|
|
|
end
|
|
|
|
end
|
|
|
|
function iterateLarge()
|
|
|
|
for i=1,100000 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()
|
2015-11-09 16:33:02 +00:00
|
|
|
Prof:detach()
|
2015-11-07 11:24:53 +00:00
|
|
|
end
|
|
|
|
if ProfOn then
|
|
|
|
Prof:draw({50})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
function love.update(dt)
|
|
|
|
Prof:attach()
|
|
|
|
iterateSmall()
|
|
|
|
iterateLarge()
|
|
|
|
if drawRect then
|
2015-11-09 16:33:02 +00:00
|
|
|
Prof:detach(true)
|
2015-11-07 11:24:53 +00:00
|
|
|
else
|
2015-11-09 16:33:02 +00:00
|
|
|
Prof:detach()
|
|
|
|
end
|
|
|
|
local data = Prof:unpack()
|
2015-11-07 11:24:53 +00:00
|
|
|
end
|
|
|
|
function love.keypressed(key)
|
2017-07-27 03:12:37 +00:00
|
|
|
if key == "escape" then
|
2015-11-07 11:24:53 +00:00
|
|
|
ProfOn = not ProfOn
|
|
|
|
elseif key == ";" then
|
|
|
|
drawRect = not drawRect
|
|
|
|
end
|
|
|
|
Prof:keypressed(key)
|
|
|
|
end
|
|
|
|
function love.mousepressed(...)
|
|
|
|
Prof:mousepressed(...)
|
|
|
|
end
|