LoadRunner function – Add Five Minutes to the current time and save as a string

I needed to write a function which adds five minutes to the current time so that I could create appointment start and end times for an application used in bank branches to make appointments for customers. The function that I’ve written could be modified to add more or less time, the clever bit is making sure that it handles the last few minutes of an hour properly.

For example.
13:56 + 5 minutes = 14:01

The function handles this by converting the 13 and the 56 into integers, doing the necessary sums and then converting the results back into strings which LoadRunner can use.

When the integers are converted back to strings, single digit number are displayed correctly e.g. 01,02,03 etc. rather than 1,2,3.
The function will not work in the last five minutes of the day because I haven’t added a function to add five minutes to 23:56 to get 00:01. (If you’re running tests this late, don’t use this function).

The sample script can be downloaded from my discussion forum.
AddFiveMinutes.zip

PAL – Performance Analysis of Logs

Today I received a report from one of the sys admin types at work. The report showed performance of a server during a test which I ran last night. He used a tool called PAL (Performance Analysis of Logs).

The tool produces nice graphs, similar to Excel 2003 (it uses Microsoft Office Web Components to produce charts).

SAmple of PAL output

 

LoadRunner Date/Time functions

LoadRunner stores date/time parameters locally on the LoadRunner PC. This means that opening a script on another users PC, where the date/time parameter is not stored, can cause corruption to the date/time parameters in a script. You know that this has happened when a date/time parameter in a format similar to this [%Y%m%d%H%M%S] is sent to the server rather than the format that you intended.

Due to this problem, we recommend that the lr_save_datetime function is used to save date or time values to a string. The string can then be used in the script and the script is portable between PCs because the script is no longer relying on the locally stored parameters.

This sample code shows different lr_save_datetime functions which can be incorporated into your scripts. As usual this sample code can be downloaded for further examination.

https://bish.co.uk/wp-content/uploads/2009/11/DateTime.zip

lr_save_datetime(“%d/%m/%y”, DATE_NOW, “DDMMYY”);
lr_output_message(“Today’s Date is %s”,lr_eval_string(“{DDMMYY}”));

lr_save_datetime(“%d/%m/%Y”, DATE_NOW, “DDMMYYYY”);
lr_output_message(“Today’s Date is %s”,lr_eval_string(“{DDMMYYYY}”));

lr_save_datetime(“%B %d %Y”, DATE_NOW, “Today”);
lr_output_message(“Today is %s”,lr_eval_string(“{Today}”));

lr_save_datetime(“%B %d %Y”, DATE_NOW + ONE_DAY, “Tomorrow”);
lr_output_message(“Tomorrow is %s”,lr_eval_string(“{Tomorrow}”));

lr_save_datetime(“%A”, DATE_NOW – ONE_DAY, “Yesterday”);
lr_output_message(“Yesterday was %s”,lr_eval_string(“{Yesterday}”));

lr_save_datetime(“%A”, DATE_NOW, “Today”);
lr_output_message(“Today is %s”,lr_eval_string(“{Today}”));

lr_save_datetime(“%A”, DATE_NOW + ONE_DAY, “Tomorrow”);
lr_output_message(“Tomorrow is %s”,lr_eval_string(“{Tomorrow}”));

lr_save_datetime(“%X”, TIME_NOW , “Time”);
lr_output_message(“The time is %s (in this locale’s date format)”,lr_eval_string(“{Time}”));

lr_save_datetime(“%X”, TIME_NOW + ONE_HOUR , “Time”);
lr_output_message(“In one hour it will be %s”,lr_eval_string(“{Time}”));

lr_save_datetime(“%A”, DATE_NOW + ONE_DAY, “Tomorrow”);
lr_output_message(“Tomorrow is %s”,lr_eval_string(“{Tomorrow}”));

lr_save_datetime(“%j”, DATE_NOW, “Today”);
lr_output_message(“Today is day %s in the year”,lr_eval_string(“{Today}”));

lr_save_datetime(“%Z”, DATE_NOW, “TimeZone”);
lr_output_message(“This machine is in the ‘%s’ time zone”,lr_eval_string(“{TimeZone}”));

lr_save_datetime(“%p”, DATE_NOW, “AMPM”);
if (strcmp (lr_eval_string(“{AMPM}”),”PM”)!=0)
{
lr_output_message(“Good Morning”);
}
else
lr_output_message(“Good Afternoon”);