API Performance
Performance monitoring utilities for apps.
picocalc.perf
Section titled “picocalc.perf”Functions
Section titled “Functions”picocalc.perf.beginFrame()
Section titled “picocalc.perf.beginFrame()”Starts timing a frame. Call at the beginning of your game loop.
- Parameters: None
- Returns: None
while true do picocalc.perf.beginFrame() -- Game logic picocalc.perf.endFrame()endpicocalc.perf.endFrame()
Section titled “picocalc.perf.endFrame()”Ends timing a frame and updates FPS calculation. Call at the end of your game loop.
- Parameters: None
- Returns: None
picocalc.perf.getFPS()
Section titled “picocalc.perf.getFPS()”Returns the current FPS, averaged over the last 30 frames.
- Parameters: None
- Returns: (number) Frames per second
local fps = picocalc.perf.getFPS()picocalc.perf.getFrameTime()
Section titled “picocalc.perf.getFrameTime()”Returns the last frame’s duration in milliseconds.
- Parameters: None
- Returns: (number) Milliseconds
local ms = picocalc.perf.getFrameTime()picocalc.perf.drawFPS([x, y])
Section titled “picocalc.perf.drawFPS([x, y])”Convenience function to draw the FPS counter on screen. Color-coded: green ≥55 FPS, yellow ≥30, red <30.
- Parameters:
x(number, optional): X coordinate. Defaults to the top-right corner: the text ends 8px from the right edge.y(number, optional): Y coordinate. Defaults to 24, just below the standard header (picocalc.ui.drawHeader), so the counter never covers its status icons.
- Returns: None
picocalc.perf.drawFPS() -- Draw at default positionpicocalc.perf.setTargetFPS(fps)
Section titled “picocalc.perf.setTargetFPS(fps)”Set target frame rate for automatic frame pacing. When set, endFrame() will sleep to maintain the target rate. Pass 0 to disable frame limiting.
- Parameters:
fps(number): Target frames per second (0= unlimited)
- Returns: None
picocalc.perf.setTargetFPS(30) -- Cap at 30 FPSpicocalc.perf.setTargetFPS(0) -- Disable frame limiting