Tracks time statistics by user and event.
In the following table, the description provides the SQL data type. If you are writing your script in Java or .NET, you should use the appropriate corresponding data type. See SQL-Java data types and SQL-.NET data types.
In SQL scripts, you can specify event parameters by name or with a question mark. Using question marks has been deprecated and it is recommended that you use named parameters. 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 want 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 |
None.
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.
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} ) ' ) |
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. (Note that 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 ); } } } |
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. (Note that 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 ); } } } } |
Discuss this page in DocCommentXchange.
|
Copyright © 2012, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.1 |