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, but 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 |
---|---|---|
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) |
2 |
s.num_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 any user during 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 script can be especially useful for time comparisons across users, events and tables.
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, table, 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' ) |
Following is the sample Java method timeStatisticsConnection. It prints statistics for the prepare_for_download event. (Note that printing statistics to the MobiLink output log might be useful at development time but would slow down a production server.)
public String timeStatisticsConnection( String username, String tableName, String eventName, int numberOfCalls, int minimumTime, int maximumTime, int totalTime ) { if( eventName.equals( "prepare_for_download") ) { java.lang.System.out.println( "prepare_for_download num_calls: " + numCalls + "total_time: " + totalTime ); } return ( null ); } |
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' ) |
Following is the sample .NET method TimeStats. It prints statistics for the prepare_for_download event. (Note that printing statistics to the MobiLink output log might be useful at development time but would slow down a production server.)
public string TimeStats( string user, string eventName, int numberOfCalls, int minimumTime, int maximumTime, int totTime ) { if( event_name=="prepare_for_download") { System.Console.WriteLine( "prepare_for_download num_calls: " + num_calls + "total_time: " + total_time ); } return ( null ); } |
Send feedback about this page via email or DocCommentXchange | Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0 |