General discussion about LÖVE, Lua, game development, puns, and unicorns.
ljdp
Party member
Posts: 209 Joined: Sat Jan 03, 2009 1:04 pm
Contact:
Post
by ljdp » Wed May 30, 2012 8:38 pm
I've created a simple profiler in response to not being able to get LuaProfiler to work with LoveJIT and some other profile not writing pretty reports.
Here's the Gist:
https://gist.github.com/2838755
Code: Select all
--[[
ProFi v1.3, by Luke Perkin 2012. MIT Licence http://www.opensource.org/licenses/mit-license.php.
Example:
ProFi = require 'ProFi'
ProFi:start()
some_function()
another_function()
coroutine.resume( some_coroutine )
ProFi:stop()
ProFi:writeReport( 'MyProfilingReport.txt' )
API:
*Arguments are specified as: type/name/default.
ProFi:start( string/once/nil )
ProFi:stop()
ProFi:checkMemory( number/interval/0, string/note/'' )
ProFi:writeReport( string/filename/'ProFi.txt' )
ProFi:reset()
ProFi:setHookCount( number/hookCount/0 )
ProFi:setGetTimeMethod( function/getTimeMethod/os.clock )
ProFi:setInspect( string/methodName, number/levels/1 )
]]
Example Report:
https://gist.github.com/2838786
Last edited by
ljdp on Wed Jun 06, 2012 10:12 pm, edited 2 times in total.
bartbes
Sex machine
Posts: 4946 Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:
Post
by bartbes » Wed May 30, 2012 9:00 pm
Looks pretty awesome, one thing I did notice though, is that you're using CPU time, not real time.
ljdp
Party member
Posts: 209 Joined: Sat Jan 03, 2009 1:04 pm
Contact:
Post
by ljdp » Wed May 30, 2012 9:08 pm
bartbes wrote: Looks pretty awesome, one thing I did notice though, is that you're using CPU time, not real time.
I care more about the relative time of functions rather than the actual time they make, I think i'll add a column to display the time as a percentage between the start and stop calls.
Roland_Yonaba
Inner party member
Posts: 1563 Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:
Post
by Roland_Yonaba » Wed May 30, 2012 9:27 pm
Nice work!
ljdp
Party member
Posts: 209 Joined: Sat Jan 03, 2009 1:04 pm
Contact:
Post
by ljdp » Wed May 30, 2012 9:29 pm
-snip-
Last edited by
ljdp on Wed May 30, 2012 11:19 pm, edited 1 time in total.
ljdp
Party member
Posts: 209 Joined: Sat Jan 03, 2009 1:04 pm
Contact:
Post
by ljdp » Wed May 30, 2012 9:41 pm
Ok it's fixed, I've added a relative time column, the time for each function is accumulative between start/stop and both time and count resets at start.
There's also a setGetTimeMethod if you want to use something different to os.clock, for example:
Code: Select all
ProFi:setGetTimeMethod( love.timer.getMicroTime )
sient
Prole
Posts: 3 Joined: Wed Apr 06, 2011 5:20 am
Post
by sient » Sun Jun 03, 2012 2:20 am
This is fantastic and just the thing I was looking for. Didn't realize the debug library had such a handy hook.
I figured for profiling you would need to use the c api, but I guess not! Never bothered to really research it.
minism
Prole
Posts: 20 Joined: Tue Nov 01, 2011 5:32 am
Post
by minism » Wed Jun 06, 2012 1:01 am
Wow, this is great, just what I was looking for a couple weeks ago. Thanks for your nice work on this.
By the way you might want to update your instructions -- ProFi:end() should be ProFi:stop()
Users browsing this forum: No registered users and 2 guests