mirror of
https://github.com/TangentFoxy/Piefiller.git
synced 2024-11-19 17:14:23 +00:00
better demo
This commit is contained in:
parent
d597cd7e67
commit
7657f31fd1
53
main.lua
53
main.lua
@ -1,53 +1,62 @@
|
|||||||
Profiler = require("piefiller")
|
profilerOn = true
|
||||||
ProfOn = true
|
|
||||||
drawRect = true
|
drawRect = true
|
||||||
local Prof = Profiler:new()
|
|
||||||
|
local Profiler = require("piefiller")
|
||||||
|
local profiler = Profiler:new()
|
||||||
|
|
||||||
function iterateSmall()
|
function iterateSmall()
|
||||||
for i=1,1000 do
|
for i=1,1000 do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function iterateLarge()
|
function iterateLarge()
|
||||||
for i=1,100000 do
|
for i=1,1000000 do
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
function iterateHuge()
|
||||||
|
for i=1,1000000000 do
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function drawRectangles()
|
function drawRectangles()
|
||||||
for i=1,100 do
|
for i=1,100 do
|
||||||
love.graphics.setColor(255,0,0)
|
love.graphics.setColor(255,0,0)
|
||||||
love.graphics.rectangle("line",i,i,i,i)
|
love.graphics.rectangle("line",i,i,i,i)
|
||||||
love.graphics.setColor(255,255,255)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function love.load()
|
|
||||||
end
|
|
||||||
function love.draw()
|
function love.draw()
|
||||||
if drawRect then
|
if drawRect then
|
||||||
drawRectangles()
|
drawRectangles()
|
||||||
Prof:detach()
|
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
Prof:attach()
|
profiler:attach()
|
||||||
|
|
||||||
iterateSmall()
|
iterateSmall()
|
||||||
iterateLarge()
|
iterateLarge()
|
||||||
if drawRect then
|
iterateHuge()
|
||||||
Prof:detach(true)
|
|
||||||
else
|
-- detached in draw function
|
||||||
Prof:detach()
|
|
||||||
end
|
|
||||||
local data = Prof:unpack()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.keypressed(key)
|
function love.keypressed(key)
|
||||||
if key == "esc" then
|
if key == "escape" then
|
||||||
ProfOn = not ProfOn
|
profilerOn = not profilerOn
|
||||||
elseif key == ";" then
|
elseif key == ";" then
|
||||||
drawRect = not drawRect
|
drawRect = not drawRect
|
||||||
end
|
end
|
||||||
Prof:keypressed(key)
|
|
||||||
|
profiler:keypressed(key)
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.mousepressed(...)
|
function love.mousepressed(...)
|
||||||
Prof:mousepressed(...)
|
profiler:mousepressed(...)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user