LoadRunnerthe scripting languageClanguage
LoadRunner supports almost all major languages, such as C ,JAVA,VB , etc. the Web (http/html) protocol uses the C language by default.
LoadRunnerScripting language Architecture
Loadrunner script mainly by action action contains 3 Independent function: vuser_init () action () , vuser_end ()
Function |
Function description |
Vuser_init () |
Typically, user-initiated operations are placed here, such as logging in, allocating memory |
Action () |
Is the business that the virtual user wants to do, is the subject of the test content |
Vuser_end () |
Corresponds to vuser_init () , doing cleanup operations, such as allocating memory for recycling, and so on. |
LoadRunnerin theClanguage
the C compiler in LoadRunner follows the C90 Standard, which specifies that in a function, the variable definition must be placed before all execution statements.
The C interpreter used to run the vuser script only supports the ANSI C language. It does not support any extensions of Microsoft to ANSI C .
LoadRunner provides a powerful collection of APIs that are sufficient to meet the needs of most performance tests. In some cases, however, these APIs still have a place that is not covered. In this case, we can do it in a way that loads the DLL .
For example:
Lr_load_dll ("Something.dll");
Somefunction ();
LoadRunnerin theC VUserfunctioncommand-line parsing functions
Function |
Function description |
Lr_get_attrib_double |
Retrieves the double type variable used in the script command line . |
Lr_get_attrib_long |
Retrieves a long type variable used in the script command line . |
Lr_get_attrib_string |
Retrieves the string used in the script command line. |
Get information
Function |
Function description |
Lr_user_data_point |
Record a sample of user-defined data. |
Lr_whoami |
Returns information about VUser to the vuser script. Not applicable for application management. |
Lr_get_host_name |
Returns the host name of the execution VUser script. |
Lr_get_master_host_name |
Returns the name of the computer running the LoadRunner controller or tuning console. Not applicable for application management. |
Transaction functions
Function |
Function description |
Lr_end_sub_transaction |
Marks the end of a child transaction for performance analysis. |
Lr_end_transaction |
Marks the end of a transaction. |
Lr_end_transaction_instance |
Marks the end of a transactional instance for performance analysis. |
Lr_fail_trans_with_error |
Sets the state of the open transaction to Lr_fail and sends an error message. |
Lr_get_trans_instance_duration |
Gets the duration of the transaction instance, as specified by its handle. |
Lr_get_trans_instance_wasted_time |
Gets the time wasted by the transaction instance, as specified by its handle. |
Lr_get_transaction_duration |
Gets the duration of the transaction, by the name of the transaction. |
Lr_get_transaction_think_time |
Gets the think time of the transaction, by the name of the transaction. |
Lr_get_transaction_wasted_time |
Gets the time that the transaction was wasted (by the name of the transaction). |
Lr_resume_transaction |
Continue to collect transaction data for performance analysis. |
Lr_resume_transaction_instance |
Continue to collect transactional instance data for performance analysis. |
Lr_set_transaction_instance_status |
Sets the state of the transaction instance. |
Lr_set_transaction_status |
Sets the state of the open transaction. |
Lr_set_transaction_status_by_name |
Sets the state of the transaction. |
Lr_start_sub_transaction |
Marks the beginning of a child transaction. |
Lr_start_transaction |
Marks the start of a transaction. |
Lr_start_transaction_instance |
Starts a nested transaction (specified by the handle of its parent transaction). |
Lr_stop_transaction |
Stop collection of transactional data. |
Lr_stop_transaction_instance |
Stops the collection of the transaction (specified by its handle) of the data. |
Lr_wasted_time |
Eliminate the time wasted on all open transactions. |
String functions
Function |
Function description |
Lr_eval_string |
Replace the parameter with the current value. |
Lr_save_string |
Saves a NULL -terminated string to the parameter. |
Lr_save_var |
Saves a variable-length string to a parameter. |
Lr_save_datetime |
Saves the current date and time to the parameter. |
LR _advance_param |
Advance to the next available parameter. |
LR _decrypt |
Decrypts the encoded string. |
Lr_eval_string_ext |
Retrieves a pointer to a buffer that contains parameter data. |
Lr_eval_string_ext_free |
Releases the pointer assigned by the LR_EVAL_STRING_EXT. |
Lr_save_searched_string |
Searches the buffer for a string instance and saves a portion of the buffer to the parameter relative to the string instance. |
Message functions
Function |
Function description |
Lr_debug_message |
Sends a debug message to the Output window or Orchestration monitor log file. |
Lr_error_message |
Sends an error message to the Output window or Orchestration monitor log file. |
Lr_get_debug_message |
Retrieves the current message class. |
Lr_log_message |
Sends a message to the log file. |
Lr_output_message |
Sends a message to the Output window or Orchestration monitor log file. |
Lr_set_debug_message |
Sets the debug message class. |
Lr_vuser_status_message |
Generates formatted output and prints it to the controller or console vuser status area. Not applicable for application management. |
Lr_message |
Sends a message to the vuser log and Output window or Orchestration monitor log file. |
Run-time functions
Function |
Function description |
Lr_load_dll |
Loads an external DLL. |
Lr_peek_events |
Indicates where the vuser script can be paused . |
Lr_think_time |
Pauses the execution of the script to simulate the think time (the time the actual user pauses between actions for thought). |
Lr_continue_on_error |
Specifies the method that handles the error. |
Lr_rendezvous |
Set the collection point in the vuser script. Not applicable for application management. |
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
C Language of the LoadRunner scripting language