CPU: Difference between revisions
Jump to navigation
Jump to search
imported>Sam Hocevar (New values.) |
imported>Sam Hocevar |
||
| Line 13: | Line 13: | ||
|- | |- | ||
| [[print|<code>print</code>]] || <code>2+n*8</code> | | [[print|<code>print</code>]] || <code>2+n*8</code> | ||
||<code>n</code> is the number of characters in the string | ||<code>n</code> is the number of characters in the string, even those not rendered | ||
spaces and | spaces, newlines, and double-width glyphs each count as one character | ||
|- | |||
| [[spr|<code>spr</code>]] || n | |||
||<code>n</code> is the number of pixels drawn, including transparent pixels (width × height of the sprite rectangle) | |||
cost is 0 if first argument is outside the [0, 255] range | |||
|- | |- | ||
| [[sspr|<code>sspr</code>]] || || | | [[sspr|<code>sspr</code>]] || <code>n</code> | ||
||<code>n</code> is the number of pixels drawn, including transparent pixels (width × height of the destination rectangle) | |||
|- | |- | ||
| [[rect|<code>rect</code>]] || || | | [[rect|<code>rect</code>]] || || | ||
Revision as of 22:17, 19 December 2018
Pico-8 keeps track of CPU usage using two values: a Lua instruction usage, and a system usage.
The function stat(1) returns the total (Lua + system) usage for the current frame, and stat(2) returns the system usage.
Only a few functions have a system usage, measured in ticks. There are 4194304 ticks in a second (2^22), so about 69905 ticks per frame at 60 FPS.
Functions with a system cost
| Function | Ticks | Notes |
cls |
1024 |
same cost as rectfill of same size
|
print |
2+n*8
|
n is the number of characters in the string, even those not rendered
spaces, newlines, and double-width glyphs each count as one character |
spr |
n | n is the number of pixels drawn, including transparent pixels (width × height of the sprite rectangle)
cost is 0 if first argument is outside the [0, 255] range |
sspr |
n
|
n is the number of pixels drawn, including transparent pixels (width × height of the destination rectangle)
|
rect |
||
rectfill |
max(1,flr(n/16)) |
n is the number of pixels drawn (width × height)
|
circ |
||
circfill |
||
line |
ceil(n/2) |
n is the number of pixels drawn; there is an additional cost of 1 if at least one pixel had to be clipped
|
map / mapdraw |
||
music |
16 |
no cost if no argument |
sfx |
16 |
no cost if no argument |
memcpy |
n+1
|
n is the number of bytes copied
|
memset |
max(1,ceil(n/2))
|
n is the number of bytes set
|
reload |
max(1,n*8)
|
n is the number of bytes reloaded
|
btn |
4 |
no cost if no argument |
btnp |
4 |
no cost if no argument |
rnd |
4 |
|
sqrt |
24 |
only 16 if argument is zero
|
stat |
16 |