标题: LoadRunner:Dynamically calculated Think Time [打印本页] 作者: pcl2004_27 时间: 2006-10-30 14:23 标题: LoadRunner:Dynamically calculated Think Time Description
a technique to pad a scripts execution time to a fixed duration
Solution
Recently in order to meet a contractual requirement I had to execute a scenario in such a way that it was of fixed duration regardless of load. I couldn抰 find any obvious way to achieve this in LoadRunner and neither could the support desk, this forced me to get a little creative with the load runner function calls. Thought I抎 post my solution here in case it抯 of use to anyone else.
With this technique I couldn抰 randomize think time using the run time settings so I also had to generate this as well. With this code the mean script execution time was typically within 15ms of the target time.
Script
{
/*
* Body of script wrapped in a timer as follows:
*/
timer = lr_start_timer();
Application抯 transactions go here?
/*
* Add some random think time.
*
* Time how long it takes to calculate the think time
* this is the recorded as wasted time.
*/
waste = lr_start_timer();
/*
* Compute think-time in the range minStepThinkTime to
* maxStepThinkTime, granularity is 1000th the difference
* between max & min values
*/