Warning Older Docs! - You are viewing documentation for a previous released version of RhoMobile Suite.

RhoProfiler API

To perform performance measurements or to find applications bottlenecks, you can use the RhoMobile Profiler API.

Refer to RhoProfiler Ruby API Examples for examples.

To enable RhoProfiler, set this in your application build.yml.

profiler: 1

These counters start working after you turn on Profiler in build.yml:

  • ERB_RENDER – ERB-file render (Ruby)
  • CTRL_ACTION – Controller action (Ruby)
  • INDEX_ACTION – Index page render
  • ERB_RENDER – ERB-file render (Ruby)
  • BROWSER_PAGE – Browser page loading time (Native)

SyncEngine components has several native counters: – Sync – Full sync time – DB – Time spend for database insert/update/delete while sync – Net – Time spend for network communication while sync

These counters works only if you create them in your application. You can create a counter in your controller action and destroy it after some operations:

Sqlite database (Native).

  • ‘SQLITE’ – counter for whole time processing SQL query including data conversion , sqlite3_step and prepare statement

  • ‘SQLITE_EXEC’ – sqlite3_step time only.

To Enable Ruby Garbage collector logging modify rhoconfig.txt (set log level to Trace):

MinSeverity = 0

create_counter

Create a global counter.

create_counter(counter_name)
counter_name the name for the global counter.

destroy_counter

Destroy a global counter. Information from the counter will be placed in the log.

destroy_counter(counter_name)
counter_name the name of the global counter to be destroyed.

start_counter

Start a local or a global counter. If Global counter with this name exists, that global counter will be started. If no global counter exists, a local counter will be created and started.

start_counter(counter_name)
counter_name the name of the counter to be started.

stop_counter

Start a local or a global counter. In case of a local counter, information from the counter will be placed in the log.

start_counter(counter_name)
counter_name the name of the counter to be stopped.

flush_counter

Get the log information from a counter (Local or Global). The counter does not have to be stopped or started for this method.

flush_counter(counter_name, message)
counter_name the name of the counter to have its information logged.
message the log information from the counter.

start_created_counter

Start a global counter. The counter will start only if it is a previously created global counter.

start_created_counter(counter_name)
counter_name the name of the previously created global counter to be started.

RhoProfiler C/C++ API

The RhoProfiler C/C++ API contains several defines to manipulate Performance Counters. Here is the list of defines.

//Global accumulative counters
#define PROF_CREATE_COUNTER(name)     // Create Global counter
#define PROF_DESTROY_COUNTER(name)    // Destroy Global counter
#define PROF_START(name) //Start Local or Global counter. If Global counter with this name exist , this global counter will started. If no global counter exists, local counter will be created and started.

#define PROF_STOP(name) // Stop Global or local counter. 
#define PROF_FLUSH_COUNTER(name,msg) //Log information from counter(Local or Global). Counter does not stopped or started. 
#define PROF_START_CREATED(name) //Counter will start only if it is already created previously(Global counter)

Example:

 #include "statistic/RhoProfiler.h"
void testFunction()
{
    PROF_CREATE_COUNTER("Counter1");

    PROF_START("Counter1");
    function1();
    PROF_STOP("Counter1");

    //do something

    PROF_START("Counter1")
    function2();
    PROF_STOP("Counter1")

    PROF_DESTROY_COUNTER("Counter1") #Will log summary of function1 and function2 execution time
}
Back to Top