Sample script using Epoch Time to demonstrate large number handling in LoadRunner

This script was provided by Steven Hedley and Steven Woodcock of Sopra Group.

They had a requirement for a script which could add time to the UNIX system time (otherwise known as Epoch time or POSIX time). Epoch time is the number of milliseconds that have passed since 00:00:00 on 1st January 1970. Many computer systems use this system to store the time as a number.

At the time of writing this article the current Epoch time is 1263400124467 this 13-digit number is too long to be used in LoadRunner calculations so to prevent errors occurring in calculations involving this number the chaps from Sopra Group have written a function to split the number into two parts (5 and 8 characters long respectively). The calculation is performed on the second 8-digit long number before the two parts are concatenated together.

The script also ensures that the final calculated time is always 13 digits long by padding any leading zeroes in the values which are used in the calculation. The function uses the web_save_timestamp_param function which returns the current EpochTime. I wasn’t familar with this function until now. Thanks!

Syntax for the function is
AddToEpoch(1800000, “ToTime”); //This takes Epoch time now and rolls it forward 30 minutes, creating a variable ToTime

As usual, the script can be downloaded at the following link:
addtoepoch

If you have samples of scripts which you feel should be shared, please let me know.


Author: Richard Bishop

http://about.me/richard_bishop