LOADRUNNER Questions and Answers

LoadRunner Function – How to get current system time

This function is developed to use in Mercury LoadRunner peformance tool. This main use of this functions to return the current system time at any given point of time while LoadRunner script is running.This function can be used to report transaction times , script start time and end time.

long get_secs_since_midnight(void)

{

char * curr_hr; /* pointer to a parameter with current clock hr */

char * curr_min; /* pointer to a parameter with current clock min*/

char * curr_sec; /* pointer to a parameter with current clock sec */

long current_time, /* current number of seconds since midnight */

hr_secs, /* current hour converted to secs */

min_secs, /* current minutes converted to secs */

secs_secs; /* current number of seconds */

curr_hr = lr_eval_string(“{current_hr}>”);

curr_min = lr_eval_string(“{current_min}”);

curr_sec = lr_eval_string(“{current_sec}”);

hr_secs = (atoi(curr_hr)) * 60 * 60;

min_secs = (atoi(curr_min)) * 60;

secs_secs = atoi(curr_sec);

current_time = hr_secs + min_secs + secs_secs;

return(current_time);

}