## ProFi, a Lua profiler that works with LuaJIT.

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:

### ProFi, a Lua profiler that works with LuaJIT.

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

--[[

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:

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

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:

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

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: 1562
Joined: Tue Jun 21, 2011 6:08 pm
Contact:

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

Nice work!

ljdp
Party member
Posts: 209
Joined: Sat Jan 03, 2009 1:04 pm
Contact:

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

-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:

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

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.

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

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

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

### Who is online

Users browsing this forum: No registered users and 13 guests