Piefiller/main.lua

75 lines
1.2 KiB
Lua
Raw Permalink 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
-- 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()
-- temporary
2017-07-27 06:08:50 +00:00
love.graphics.setColor(255, 255, 255, 255)
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()
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
2017-07-27 06:08:50 +00:00
function love.wheelmoved(x, y)
if y < 0 then
-- up
profiler.scale = profiler.scale - 0.1
else
-- down
profiler.scale = profiler.scale + 0.1
end
end