Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 17 » MobiLink - Server Administration » MobiLink events » Synchronization events

time_statistics connection event

Tracks time statistics by user and event.

Parameters

In the following table, the description provides the SQL data type. If you are writing your script in Java or .NET, use the appropriate corresponding data type.

In SQL scripts, you can specify event parameters by name or with a question mark. Using question marks has been deprecated. Use named parameters instead. You cannot mix names and question marks within a script. If you use question marks, the parameters must be in the order shown below and are optional only if no subsequent parameters are specified (for example, you must use parameter 1 if you are going to use parameter 2). If you use named parameters, you can specify any subset of the parameters in any order.

Parameter name for SQL scripts Description Order (deprecated for SQL)
s.remote_id VARCHAR(128). The MobiLink remote ID. You can only reference the remote ID if you are using named parameters. Not applicable

s.username

VARCHAR(128). The MobiLink user name.

1

s.event_name

VARCHAR(128). The event whose statistics are being reported.

2

s.number_of_calls

INTEGER. The number of times the script was called.

3

s.minimum_time

INTEGER. Milliseconds. The shortest time it took to execute a script during this synchronization.

4

s.maximum_time

INTEGER. Milliseconds. The longest time it took to execute a script during this synchronization.

5

s.total_time

INTEGER. Milliseconds. The total time it took to execute all scripts in the synchronization. (This is not the same as the length of the synchronization.)

6

s.script_version VARCHAR(128). Optional IN parameter to specify that the MobiLink server passes the script version string used for the current synchronization to this parameter. Question marks cannot be used to specify this parameter. Not applicable
Default action

None.

Remarks

The time_statistics event allows you to gather time statistics for a synchronization. The statistics are gathered only for those events for which there is a corresponding script. The script gathers aggregate data for occasions where a single event occurs multiple times.

SQL example

The following example inserts statistical information into the time_statistics table.

CALL ml_add_connection_script(
  'ver1',
  'time_statistics',
  'INSERT INTO time_statistics (
    id, 
    ml_user, 
    event_name, 
    number_of_calls, 
    minimum_time, 
    maximum_time, 
    total_time)
   VALUES (
    ts_id.nextval,
    {ml s.username}, 
    {ml s.event_name}, 
    {ml s.number_of_calls}, 
    {ml s.minimum_time}, 
    {ml s.maximum_time}, 
    {ml s.total_time} ) ' )
Java example

The following call to a MobiLink system procedure registers a Java method called timeStatisticsConnection as the script for the time_statistics connection event when synchronizing the script version ver1.

CALL ml_add_java_connection_script(
  'ver1',
  'time_statistics',
  'ExamplePackage.ExampleClass.timeStatisticsConnection' )

The following is the sample Java method timeStatisticsConnection. It prints statistics for the prepare_for_download event. (Printing statistics to the MobiLink message log might be useful at development time but would slow down a production server.)

package ExamplePackage; 
public class ExampleClass
{
    public void timeStatisticsConnection(
                      String	username,
					  String	eventName,
					  int		numberOfCalls, 
					  int		minimumTime, 
					  int		maximumTime,
					  int		totalTime ) 
    {
	if( eventName.equals( "prepare_for_download") ) {
	    System.out.println( "prepare_for_download num_calls: " + numberOfCalls +
				" total_time: " + totalTime ); 
	}
    }
}
.NET example

The following call to a MobiLink system procedure registers a .NET method called TimeStats as the script for the time_statistics connection event when synchronizing the script version ver1.

CALL ml_add_dnet_connection_script(
  'ver1',
  'time_statistics',
  'TestScripts.Test.TimeStats'
)

The following is the sample .NET method TimeStats. It prints statistics for the prepare_for_download event. (Printing statistics to the MobiLink message log might be useful at development time but would slow down a production server.)

namespace TestScripts
{
    public class test
    {
	public void TimeStats( string	user,
			       string	eventName,
			       int	numberOfCalls,
			       int	minimumTime,
			       int	maximumTime,
			       int	totTime ) 
	{
	    if( eventName == "prepare_for_download" ) {
		System.Console.WriteLine( "prepare_for_download num_calls: " + numberOfCalls +
					  "total_time: " + totTime ); 
	    } 
	}
    }
}