CPU: Difference between revisions
Jump to navigation
Jump to search
imported>Sam Hocevar mNo edit summary |
imported>Sam Hocevar (New values.) |
||
| Line 12: | Line 12: | ||
| [[cls|<code>cls</code>]] || <code>1024</code> || same cost as [[rectfill|<code>rectfill</code>]] of same size | | [[cls|<code>cls</code>]] || <code>1024</code> || same cost as [[rectfill|<code>rectfill</code>]] of same size | ||
|- | |- | ||
| [[print|<code>print</code>]] || || | | [[print|<code>print</code>]] || <code>2+n*8</code> | ||
||<code>n</code> is the number of characters in the string | |||
spaces and newlines count as one character | |||
double-width glyphs count as one character | |||
offscreen characters count | |||
|- | |- | ||
| [[spr|<code>spr</code>]] || || | | [[spr|<code>spr</code>]] || || | ||
| Line 34: | Line 41: | ||
| [[sfx|<code>sfx</code>]] || <code>16</code> || no cost if no argument | | [[sfx|<code>sfx</code>]] || <code>16</code> || no cost if no argument | ||
|- | |- | ||
| [[memcpy|<code>memcpy</code>]] || || | | [[memcpy|<code>memcpy</code>]] || <code>n+1</code> | ||
||<code>n</code> is the number of bytes copied | |||
|- | |- | ||
| [[memset|<code>memset</code>]] || || | | [[memset|<code>memset</code>]] || <code>max(1,ceil(n/2))</code> | ||
||<code>n</code> is the number of bytes set | |||
|- | |- | ||
| [[reload|<code>reload</code>]] || || | | [[reload|<code>reload</code>]] || <code>max(1,n*8)</code> | ||
||<code>n</code> is the number of bytes reloaded | |||
|- | |- | ||
| [[btn|<code>btn</code>]] || <code>4</code> || no cost if no argument | | [[btn|<code>btn</code>]] || <code>4</code> || no cost if no argument | ||
Revision as of 21:56, 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
spaces and newlines count as one character double-width glyphs count as one character offscreen characters count |
spr |
||
sspr |
||
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 |