Page 1 of 1

ProFi, a Lua profiler that works with LuaJIT.

Posted: Wed May 30, 2012 8:38 pm
by ljdp
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

Re: ProFi, a Lua profiler that works with LuaJIT.

Posted: Wed May 30, 2012 9:00 pm
by bartbes
Looks pretty awesome, one thing I did notice though, is that you're using CPU time, not real time.

Re: ProFi, a Lua profiler that works with LuaJIT.

Posted: Wed May 30, 2012 9:08 pm
by ljdp
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.

Re: ProFi, a Lua profiler that works with LuaJIT.

Posted: Wed May 30, 2012 9:27 pm
by Roland_Yonaba
Nice work!

Re: ProFi, a Lua profiler that works with LuaJIT.

Posted: Wed May 30, 2012 9:29 pm
by ljdp
-snip-

Re: ProFi, a Lua profiler that works with LuaJIT.

Posted: Wed May 30, 2012 9:41 pm
by ljdp
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 )

Re: ProFi, a Lua profiler that works with LuaJIT.

Posted: Sun Jun 03, 2012 2:20 am
by sient
This is fantastic and just the thing I was looking for. Didn't realize the debug library had such a handy hook. :neko:

I figured for profiling you would need to use the c api, but I guess not! Never bothered to really research it.

Re: ProFi, a Lua profiler that works with LuaJIT.

Posted: Wed Jun 06, 2012 1:01 am
by minism
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()