@@ -85,6 +85,38 @@ function love.load(arg)
8585 })
8686end
8787
88+ -- local SAMPLES = 10
89+ -- local profiling = {}
90+ -- local last_state
91+ --
92+ -- function updateProfiling(dt)
93+ -- local state = last_state
94+ -- last_state = SWITCHER.current()
95+ -- if not state then return end
96+ -- local name = "???"
97+ -- for k,v in pairs(GS) do
98+ -- if v == state then
99+ -- name = k
100+ -- break
101+ -- end
102+ -- end
103+ -- if dt > 0.2 then
104+ -- print("lag on state", name)
105+ -- end
106+ -- local sample = profiling[name] or { times = {} , n = 1 }
107+ -- sample.times[sample.n] = dt
108+ -- sample.n = (sample.n % SAMPLES) + 1
109+ -- profiling[name] = sample
110+ -- end
111+ --
112+ -- function average(sample)
113+ -- local sum = 0
114+ -- for _,time in ipairs(sample.times) do
115+ -- sum = sum + time
116+ -- end
117+ -- return sum / math.max(#sample.times, SAMPLES)
118+ -- end
119+
88120function love .update (dt )
89121 MAIN_TIMER :update (dt )
90122 if INPUT .wasActionReleased (' QUIT' ) then
@@ -97,6 +129,7 @@ function love.update(dt)
97129 SWITCHER .push (GS .DEVMODE )
98130 end
99131 SWITCHER .update (dt )
132+ -- updateProfiling(dt)
100133 INPUT .flush () -- must be called afterwards
101134 Util .updateSubtype (dt , ' task' )
102135 Draw .update (dt )
106139
107140function love .draw ()
108141 SWITCHER .draw ()
142+ -- local g = love.graphics
143+ -- g.push()
144+ -- g.origin()
145+ -- g.setColor(1,1,1)
146+ -- local i = 0
147+ -- for name,sample in pairs(profiling) do
148+ -- g.print(("%s: %.2f"):format(name, 1 / average(sample)), 32, 32+i*32)
149+ -- i = i + 1
150+ -- end
151+ -- g.pop()
109152end
110153
111154function love .quit ()
0 commit comments