Load Runner中是否有任何可用的函数来获取变量中的运行时设置

问题描述 投票:0回答:1

我正在尝试在我的加载运行器脚本中创建一个循环,该循环将一直运行直到起搏时间等于零。下面是硬编码脚本。

在这里,我需要硬编码在运行时设置中定义的调步时间。我们是否有任何功能可以将运行时设置中定义的调步时间变为变量。

 int pacingtime = 600;
 starttime = time();
 <Web Requests>
 endtime = time();
 diff = endtime - starttime;
 waittime = pacingtime - diff;
label1:
s1 = time();
<Web Custom Requests>
s2 = time();
s3 = s2 - s1
count = waittime - s3;
waittime = waittime - s3;
 if (count < 0)
     goto label1;
 else
     goto label2;

label2:
return 0;

谢谢!

loadrunner
1个回答
0
投票

请考虑此代码,它对您的问题有影响。在运行时设置中,将迭代次数设置为100,不进行任何调整。在附加属性中,为“pacing”添加值为2.执行并查看日志。

long pacing;

vuser_init()
{
    pacing=lr_get_attrib_long("pacing");

    lr_message("pacing: %d",pacing);

    if (pacing==0){ 
        lr_message("Illegal value"); 
    }

    return 0;
}

Action()
{   double how_long;
    merc_timer_handle_t timer=lr_start_timer();

    sleep(rand()%(pacing*1000)+1000);

    how_long=lr_end_timer(timer);

    if ( how_long >= pacing )
    {
        lr_message("delayed %lf seconds, longer than %d seconds\r\nEnding Iterations",
        how_long,
        pacing);

        return -1;
    }
    else
    {
        lr_message("delayed %lf seconds, less than %d seconds\r\nSleeping %lf seconds",
        how_long,
        pacing,
        ((double)pacing-how_long));     
    }

    return 0;
}

vuser_end()
{
    return 0;
}
© www.soinside.com 2019 - 2024. All rights reserved.