ProFi, a Lua profiler that works with LuaJIT.

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
ljdp
Party member
Posts: 209
Joined: Sat Jan 03, 2009 1:04 pm
Contact:

ProFi, a Lua profiler that works with LuaJIT.

Post 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
Last edited by ljdp on Wed Jun 06, 2012 10:12 pm, edited 2 times in total.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

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

Post by bartbes »

Looks pretty awesome, one thing I did notice though, is that you're using CPU time, not real time.
User avatar
ljdp
Party member
Posts: 209
Joined: Sat Jan 03, 2009 1:04 pm
Contact:

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

Post 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.
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

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

Post by Roland_Yonaba »

Nice work!
User avatar
ljdp
Party member
Posts: 209
Joined: Sat Jan 03, 2009 1:04 pm
Contact:

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

Post by ljdp »

-snip-
Last edited by ljdp on Wed May 30, 2012 11:19 pm, edited 1 time in total.
User avatar
ljdp
Party member
Posts: 209
Joined: Sat Jan 03, 2009 1:04 pm
Contact:

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

Post 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 )
sient
Prole
Posts: 3
Joined: Wed Apr 06, 2011 5:20 am

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

Post 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.
minism
Prole
Posts: 20
Joined: Tue Nov 01, 2011 5:32 am

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

Post 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()
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests