How to get time duration in millisecond in WinRunner?

How to get time duration in millisecond in WinRunner?


All we have to do is save the start time 

(get_time()) at the start and at the end of 

the test and then format the difference in 

terms of the seconds passed between.

The code below will do what you want and more : 

const SECOND = 1;

const MINUTE = 60 * SECOND;

const HOUR = MINUTE * 60;

const DAY = HOUR * 24;

const YEAR = DAY * 365;

public function dddt_CalculateDuration

(in oldTime,in newTime, out strDuration,

out years, out months,out days, out hours,

out minutes, out seconds)

{

auto timeDiff, plural = \"s, \", 

singular = \", \", remainder;


    timeDiff = oldTime - newTime;


if(timeDiff >= YEAR)

{

    remainder = timeDiff % YEAR;

years = (timeDiff - remainder) / YEAR;

    timeDiff = remainder;

}


if(timeDiff >= DAY)

{

    remainder = timeDiff % DAY;

days = (timeDiff - remainder) / DAY;

    timeDiff = remainder;

}


if(timeDiff >= HOUR)

{

    remainder = timeDiff % HOUR;

hours = (timeDiff - remainder) / HOUR;

    timeDiff = remainder;

}


if(timeDiff >= MINUTE)

{

    remainder = timeDiff % MINUTE;

minutes = (timeDiff - remainder) / MINUTE;

    timeDiff = remainder;

}


seconds = timeDiff;


strDuration = \"\";


if (years)

{

strDuration = years & \" Year\";

if (years > 1)

 strDuration = strDuration & plural;

else

 strDuration = strDuration & singular;

}


if (days)

{

strDuration = strDuration & days & \" Day\";

    if (days > 1)

strDuration = strDuration & plural;

    else

 strDuration = strDuration & singular;

}


if (hours)

{

strDuration = strDuration & hours & \" Hour\";

    if (hours > 1)

strDuration = strDuration & plural;

    else

strDuration = strDuration & singular;

}


if (minutes)

{

strDuration = strDuration & minutes & \" Minute\";

    if (minutes > 1)

        strDuration = strDuration & plural;

    else

        strDuration = strDuration & singular;

}


if (seconds)

{

strDuration = strDuration & seconds & \" Second\";

    if (seconds > 1)

        strDuration = strDuration & \"s.\";

    else

        strDuration = strDuration & \".\";

}


return E_OK;

}



By:UMANG
Date:2002-02-09 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related TESTING Subjective Links

TESTING Subjective interview questions and answers for experienced and fresher