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 API functions that can be used at runtime to extract and display performance information.

grd_fps (string, 1s0)

The frame rate of display updates averaged over the last 5 seconds of display. This variable is only created and filled in if the -oscreen_mgr,fps option is passed to the Storyboard Engine.

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 a periodic Lua script can be used to extract the local FPS The FPS value is stored as a string variable and may not exist until enough frames of data have been generated to derive a value.

-- Take a snapshot of the current execution metrics
function snapshot_metrics()
    local fps = gre.get_value("grd_fps") or 0 
    local mem = gre.env("mem_stats")
    local lua_mem = collectgarbage("count")
    
    --Normalize, not all systems have all data
    if(fps ~= nil) then
        print(string.format("FPS  : %d", tonumber(fps)))
    end
    if(mem.process_used) then
        print(string.format("MEM  : %d", mem.process_used))
    end
    if(mem.heap_used) then
        print(string.format(" HEAP: %d", mem.heap_used))
    end
    print(string.format(" LUA : %d", lua_mem))
end

-- Set up a periodic timer to snapshot execution metrics every 1s
function init_metric_snapshot(mapargs)
    gre.timer_set_interval(snapshot_metrics, 1000)
end
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Article is closed for comments.