Measuring Performance

Using the Storyboard logger plugin it is possible to capture metrics detailing various aspects of a Storyboard applications performance. These metrics include screen, layer and control redraw times, action execution times and general event processing times. If a performance log file is captured as and saved with the file extension .plog (for performance log) then Storyboard Designer will automatically recognize it and open up a log file viewer that provides an organized display and base analysis of the performance events.

For more information on options to configure and control the performance monitoring of the engine, refer to the Logger plugin section of this document and the gra.perf_state action.

The Storyboard Embedded Engine runtime also provides a number of internal variables and API functions that can be used at runtime to display performance information.

grd_fps (string, 1s0)

The frame rate of display updates averaged over the last 5 seconds of display. This value is only generated if the -oscreen_mgr,fps option is passed along to the sbengine binary.

Storyboard display updates are entirely event driven, so unless the application that is being run is continuously changing content or generating redraw events such as is frequently done by benchmarking applications, this value may not reflect the true drawing performance of the system.

gre.env("mem_stats") (Lua)

On systems where this information is available this returns the amount of process and heap memory that the Storyboard Engine is using.

collectgarbage("collect") (Lua)

This is a Lua API call and will identify how much memory the Lua script interpreter is consuming. This will be a subset of the information returned by gre.env().

This sample demonstrates how you can use a Lua script to extract and print the FPS value to the display. The FPS value is stored as a string variable and can be referenced directly within a text render extension.

function show_fps(mapargs)
    local value = gre.get_value("grd_fps")

    -- FPS generated every 5s, assuming: -oscreen_mgr,fps
    if(value ~= nil) then
        local msg = string.format("Screen FPS: %d", value)
        print(msg)
    end
end