2015-11-07 11:18:57 +00:00
|
|
|
# Piefiller
|
2017-07-27 03:48:46 +00:00
|
|
|
|
|
|
|
Graphical profiler for Love2D >= 0.9.2
|
|
|
|
|
|
|
|
Originally by devfirefly, heavily modified by Guard13007.
|
|
|
|
|
2017-07-25 04:04:47 +00:00
|
|
|
# Usage
|
2017-07-27 03:48:46 +00:00
|
|
|
|
|
|
|
1) Require the file:
|
2015-11-07 11:44:49 +00:00
|
|
|
```lua
|
2017-07-27 03:48:46 +00:00
|
|
|
local piefiller = require("piefiller")
|
2015-11-07 11:44:49 +00:00
|
|
|
```
|
2017-07-27 03:48:46 +00:00
|
|
|
2) Make a new instance of piefiller:
|
2015-11-07 11:44:49 +00:00
|
|
|
```lua
|
2017-07-27 03:48:46 +00:00
|
|
|
local Pie = piefiller:new()
|
2015-11-07 11:44:49 +00:00
|
|
|
```
|
2017-07-27 03:48:46 +00:00
|
|
|
3) Attach the piefiller to the part of your application that you want to monitor (love.update and love.draw typically are good places):
|
2015-11-07 11:44:49 +00:00
|
|
|
```lua
|
|
|
|
function love.update()
|
|
|
|
Pie:attach()
|
|
|
|
-- do something
|
2017-02-04 09:20:37 +00:00
|
|
|
Pie:detach()
|
2015-11-07 11:44:49 +00:00
|
|
|
end
|
|
|
|
```
|
2017-07-27 05:15:35 +00:00
|
|
|
4) Draw the output and pass key events to your piefiller:
|
2015-11-07 11:44:49 +00:00
|
|
|
```lua
|
|
|
|
function love.draw()
|
|
|
|
Pie:draw()
|
|
|
|
end
|
2017-07-27 03:48:46 +00:00
|
|
|
function love.keypressed(key)
|
|
|
|
Pie:keypressed(key)
|
2015-11-07 11:44:49 +00:00
|
|
|
end
|
|
|
|
```
|
2017-07-27 04:15:05 +00:00
|
|
|
5) With sufficient output, press the `E` key to output to file. Example output:
|
|
|
|
```
|
|
|
|
-----drawRectangles-----
|
|
|
|
source:@main.lua:20
|
|
|
|
current line: 22
|
|
|
|
time: 548.325
|
|
|
|
percentage: 98 %
|
|
|
|
----------------
|
|
|
|
```
|
2017-07-27 03:48:46 +00:00
|
|
|
|
2017-07-25 04:07:49 +00:00
|
|
|
# Keys
|
2015-11-07 11:44:49 +00:00
|
|
|
|
2017-07-27 03:48:46 +00:00
|
|
|
p = shows/hides the profiler
|
|
|
|
|
|
|
|
r = resets the pie
|
|
|
|
|
|
|
|
up = decreases depth
|
2015-11-07 11:44:49 +00:00
|
|
|
|
2017-07-27 03:48:46 +00:00
|
|
|
down = increases depth
|
2015-11-07 11:44:49 +00:00
|
|
|
|
2017-07-27 04:15:05 +00:00
|
|
|
\- = decreases step size
|
2015-11-07 11:44:49 +00:00
|
|
|
|
2017-07-27 03:48:46 +00:00
|
|
|
= = increases step size
|
2015-11-07 11:44:49 +00:00
|
|
|
|
|
|
|
s = shortens the names displayed
|
|
|
|
|
2017-07-27 03:48:46 +00:00
|
|
|
h = shows/hides hidden processes
|
|
|
|
|
|
|
|
e = saves to file called "Profile.txt" and opens directory for you
|
2015-11-07 11:44:49 +00:00
|
|
|
|
2015-11-09 16:45:48 +00:00
|
|
|
## To redefine these:
|
2017-07-27 03:48:46 +00:00
|
|
|
|
|
|
|
Commands available:
|
2015-11-09 16:54:44 +00:00
|
|
|
```lua
|
|
|
|
reset
|
|
|
|
increase_depth
|
|
|
|
decrease_depth
|
|
|
|
increase_step_size
|
|
|
|
decrease_step_size
|
|
|
|
shorten_names
|
|
|
|
show_hidden
|
|
|
|
save_to_file
|
2017-07-27 03:48:46 +00:00
|
|
|
show_profiler
|
2015-11-09 16:54:44 +00:00
|
|
|
```
|
|
|
|
|
2017-07-27 03:48:46 +00:00
|
|
|
To redefine only one of the keys:
|
2015-11-09 16:54:44 +00:00
|
|
|
```lua
|
2017-07-27 03:48:46 +00:00
|
|
|
piefiller:setKey(command, key)
|
2015-11-09 16:54:44 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
example:
|
|
|
|
|
|
|
|
```lua
|
|
|
|
piefiller:setKey("increase_depth","up")
|
|
|
|
```
|
2017-07-27 03:48:46 +00:00
|
|
|
|
2015-11-09 16:45:48 +00:00
|
|
|
To redefine all of the keys:
|
2015-11-09 16:54:44 +00:00
|
|
|
```lua
|
|
|
|
table = {
|
|
|
|
"increase_depth" = "up"
|
|
|
|
}
|
|
|
|
piefiller:setKey(table)
|
|
|
|
```
|
2017-07-27 03:48:46 +00:00
|
|
|
|
|
|
|
# For your own interpretation
|
|
|
|
|
2017-07-27 04:15:05 +00:00
|
|
|
If you wish to interpret the data on your own use `piefiller:unpack()`.
|
|
|
|
Output is a table as such:
|
2017-07-27 03:48:46 +00:00
|
|
|
|
2015-11-09 16:54:44 +00:00
|
|
|
```lua
|
|
|
|
data = {
|
2017-07-27 03:48:46 +00:00
|
|
|
items = {
|
|
|
|
{
|
2015-11-09 16:54:44 +00:00
|
|
|
name,
|
2017-07-27 03:48:46 +00:00
|
|
|
line_defined,
|
2015-11-09 16:54:44 +00:00
|
|
|
current_line,
|
|
|
|
source,
|
2017-07-27 03:48:46 +00:00
|
|
|
time_taken,
|
2015-11-09 16:54:44 +00:00
|
|
|
percentage,
|
|
|
|
caller,
|
|
|
|
}
|
2017-07-27 03:48:46 +00:00
|
|
|
},
|
2015-11-09 16:54:44 +00:00
|
|
|
about = {
|
|
|
|
depth,
|
2017-07-27 03:48:46 +00:00
|
|
|
step,
|
2015-11-09 16:54:44 +00:00
|
|
|
totalTime,
|
2017-07-27 03:48:46 +00:00
|
|
|
},
|
|
|
|
}
|
2015-11-09 16:54:44 +00:00
|
|
|
```
|
2017-07-27 03:48:46 +00:00
|
|
|
|
2015-11-07 11:44:49 +00:00
|
|
|
# Additional notes
|
|
|
|
|
2017-07-27 03:48:46 +00:00
|
|
|
The best depth to search in is usually 2 and sometimes 3.
|
|
|
|
|
|
|
|
When used in large applications the output may be too much to read, however you
|
|
|
|
most likely will only be wanting to optimize the most expensive items. (And you
|
|
|
|
can always output the data to review later.)
|