love.diary - a basic profiling library

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
hughes
Prole
Posts: 21
Joined: Fri Oct 28, 2011 3:10 am

love.diary - a basic profiling library

Post by hughes »

Here is a little library that will help you determine where your program is slowing down.

Usage:
At some point, start a timer:

Code: Select all

Diary.start("Main Loop")
Then stop it somewhere:

Code: Select all

Diary.stop("Main Loop")
You can add a timer as a child of another timer

Code: Select all

Diary.stop("Draw call", "Main Loop") -- this timer is a child of the Main Loop timer
You can auto-attach entries by calling

Code: Select all

Diary.autoAttach("Name of default timer")
Then reset the default:

Code: Select all

Diary.autoAttach()
You can add as many levels of children as you want. Try not to make infinite loops.

Get the status of the diary with

Code: Select all

Diary.toStr()
This can be printed with

Code: Select all

love.graphics.print(Diary.toStr(), x,y)
or simply with

Code: Select all

print(Diary.toStr())
Example output:

Code: Select all

[+] Main Loop: 49.8 ms
 |  [+] Update: 51.08 ms
 |   |  [+] Reticulating Splines: 51.08 ms
 |   |   |  Subtask a: 33.07 ms
 |   |   |  Subtask b: 17.99 ms
 |  [+] Draw: 6.98 ms
 |   |  Printing Text: 1.27 ms
 |   |  Lubricating freewheel unit: 5.69 ms
A top-level entry: 5.99 ms
See attached library and sample love file. Won't work across threads. Tested only in 0.8.0.

Please try it out and tell me how it can be made better! Try to break it!
Attachments
love.diary.love
(347.42 KiB) Downloaded 78 times
diary.lua
(2.73 KiB) Downloaded 78 times
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: love.diary - a basic profiling library

Post by TechnoCat »

Have it output to a file the average times after a set number of iterations or something.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: love.diary - a basic profiling library

Post by Jasoco »

This looks like it could be useful in conjunction with my own Debugging library.
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: love.diary - a basic profiling library

Post by vrld »

Looks nice, especially the output. But the lib should also show the average execution time and the number of calls to effectively profile stuff. Also, what is the benefit over using luaprofiler?
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
hughes
Prole
Posts: 21
Joined: Fri Oct 28, 2011 3:10 am

Re: love.diary - a basic profiling library

Post by hughes »

vrld wrote:what is the benefit over using luaprofiler?
Um - i guess the only benefit is that for some reason I thought it was easier to write my own than to google if something like that already existed. Damn.

Nothing to see here folks...
User avatar
Ellohir
Party member
Posts: 235
Joined: Sat Oct 22, 2011 11:12 pm

Re: love.diary - a basic profiling library

Post by Ellohir »

Good job anyway ;)
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: love.diary - a basic profiling library

Post by rude »

vrld wrote:Also, what is the benefit over using luaprofiler?
love.diary has a cooler name, and by LÖVE-logic, is therefore cooler.

If cool counts as a benefit. (Hint: it does)
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 208 guests