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 of the performance events.

For more information on the performance monitoring plugin and its capabilities, 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 that can be used at runtime to display performance information. The following Storyboard variables, can be used to extract information from the runtime:

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.

grd.animation.name (string, 1s0)

The name of the last completed animation.

grd.animation.frames (number, 4s0)

The number of frames rendered for the last animation run.

grd.animation.duration (number, 4s1)

The duration in milliseconds (ms) of the last animation run.

This sample demonstrates how you can use a Lua script to extract and print these values to the display.

function show_metrics(mapargs)
    local fps_key = "grd_fps"
    local name_key = "grd.animation.name"
    local frame_key = "grd.animation.frames"
    local duration_key = "grd.animation.duration"

    local msg
    local data = gre.get_data(fps_key, name_key, frame_key, duration_key)

    -- FPS generated every 5s, assuming: -oscreen_mgr,fps
    if(data[fps_key]) then
        msg = string.format("Screen FPS: %d", data[fps_key])
        print(msg)
    end

    -- Animation data only available after animation complete
    if(data[name_key]) then
        msg = string.format("Animation %s took %d ms @ %d fps", data[name_key],
        data[duration_key], data[frame_key])
        print(msg)
    end
end