Over the years, it seems as if I have written the same functions again and again in different LoadRunner scripts. It usually seems to be functions to write to a file, or to do simple string manipulation, but sometimes it is more complicated and I waste a lot of time writing code that someone else (or sometimes me) has already written.
To save you (and my future self) some time, I have collected my LoadRunner functions into a library called lr-libc, and made it available at https://github.com/MyLoadTest/lr-libc.
If one of the functions looks like it will solve your problem, you can simply cut and paste it into your LoadRunner script (e.g. into your globals.h file) and not have to waste time reinventing the wheel.
LoadRunner-specific Functions (lrlib.h)
|lrlib_think_time||Pauses the execution of the vuser for the specified number of seconds. This think time cannot be ignored by the script’s runtime settings.|
|lrlib_print_log_options||Prints logging options to the replay log.|
|lrlib_force_output_message||Writes a message to the replay log, even if logging is disabled.|
|lrlib_set_log_level||Sets new logging options to specify what information should be written to the replay log.|
|lrlib_get_vuser_pid||Gets the process ID of the mmdrv.exe process that is running the VuGen script that called this function.|
|lrlibc_kill_all_mmdrv||Kills all running mmdrv.exe processes (except the one used by the script that called this function).|
File-related Functions (files.h)
|lrlib_file_exists||Checks if a file already exists on the filesystem.|
|lrlib_get_file_size||Gets the size of a file in bytes.|
|lrlib_save_file||Saves a file to the hard disk.|
|lrlib_append_to_file||Writes a string to the end of a file.|
|lrlib_read_text_file||Reads a text file and saves its contents to a parameter.|
String Manipulation Functions (strings.h)
|lrlib_str_split||Splits a delimited string and saves the elements to a parameter array|
|lrlib_str_reverse||Reverses the order of the characters in a string.|
|lrlib_str_trim||Strips whitespace characters from the beginning and end of a
|lrlib_sapeventqueue_decode||Decodes SAPEVENTQUEUE-encoded characters|
|lrlib_sapeventqueue_encode||Encodes special characters using SAPEVENTQUEUE encoding|
Monitoring Functions (monitors.h)
MySQL-related Functions (mysql.h)
Please see the GitHub repository page for instructions on how you can contribute your own code, and how to raise bugs and feature requests.