Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
LR merc定时器手柄_C_Sockets_Automated Tests - Fatal编程技术网

LR merc定时器手柄

LR merc定时器手柄,c,sockets,automated-tests,C,Sockets,Automated Tests,我想使用“merc\u timer\u handle\t”在loadrunner中记录时间,但当我创建场景时,LR在“master”附近的第15行给出一条错误消息:“语法错误” 我想知道如何使用“merc\u timer\u handle\u t”,这是我的脚本 #define _EOF '#' #include "lrs.h" #include "web_api.h" Action () { char *recvbuf; int recvlen=0; int rc;

我想使用
“merc\u timer\u handle\t”
在loadrunner中记录时间,但当我创建场景时,LR在“master”附近的第15行给出一条错误消息:
“语法错误”

我想知道如何使用
“merc\u timer\u handle\u t”
,这是我的脚本

#define _EOF '#'
#include "lrs.h"
#include "web_api.h"

Action ()
{
    char *recvbuf;
    int recvlen=0;
    int rc;
    double trans_time;

    int i, baseIter = 1000; 
    char dude[1000]; 
    double wasteTime, actualElapsedTime; 
    merc_timer_handle_t MasterT, timer;
    int n = 100;


    rc = lrs_create_socket("socket0", "TCP", "LocalHost=0", "RemoteHost=192.168.1.130:10001", LrsLastArg);  

    if (rc = 0 ) 
    {
        lr_end_transaction("Conn_socket", LR_PASS);

        return 0;
    }
    else 
    {

    }

        //Start transaction 
    lr_start_transaction("Conn_socket");

    // Examine the total elapsed time of the action 

    MasterT = lr_start_timer(); 

    // Create some elapsed time for the transaction 
    for (i=0; i< 100; ++i) 

            sprintf(dude, 

                "This is the way we create elapsed time artificially = %d", i); 


    // Create some wasted time and record it with timer 
    timer = lr_start_timer(); 

    for (i=0; i< 100; ++i) 

            sprintf(dude, 

                "This is the way we waste time in a script = %d", i); 

    wasteTime = lr_end_timer(timer); 

    lr_output_message("User created waste time = %lf", wasteTime); 

    lr_output_message("Before lr_waste_time: Duration = %lf - Waste = %lf",         

    lr_get_transaction_duration("Conn_socket"), 

    lr_get_transaction_wasted_time("Conn_socket")); 

    /* Convert Timer in seconds to wasted time in milliseconds 

     and add to internally generated waste time */ 

    wasteTime *= 1000; 

    lr_wasted_time(wasteTime); 

    lr_output_message("After lr_waste_time: Duration = %lf - Waste = %lf", 

    lr_get_transaction_duration("Conn_socket"), 

    lr_get_transaction_wasted_time("Conn_socket")); 

    lr_output_message("Think time = %lf",lr_get_transaction_think_time("Conn_socket")); 


    lrs_send("socket0","buf0", LrsLastArg);

    lrs_receive ("socket0","buf1",LrsLastArg);

    lrs_get_last_received_buffer ("socket0",&recvbuf,&recvlen);

    lrs_send("socket0", "buf2", LrsLastArg);

    lrs_receive("socket0", "buf3", LrsLastArg);

    lrs_send("socket0", "buf4", LrsLastArg);

    lrs_receive("socket0", "buf5", LrsLastArg);

    lrs_send("socket0", "buf6", LrsLastArg);

    lrs_receive("socket0", "buf7", LrsLastArg);

    lrs_send("socket0", "buf8", LrsLastArg);

    lrs_receive("socket0", "buf9", LrsLastArg);


    lr_end_transaction("Conn_socket",LR_AUTO); 

    actualElapsedTime = lr_end_timer(MasterT); 

    lr_output_message("Total Elapsed time for Action = %lf", actualElapsedTime);     

    lrs_close_socket("socket0");

    return 0;
}
#定义#EOF'#'
#包括“lrs.h”
#包括“web_api.h”
行动()
{
char*recvbuf;
int recvlen=0;
int rc;
双传输时间;
int i,baseIter=1000;
查尔杜德[1000];
双倍浪费时间,实际最短时间;
水星定时器,手柄,定时器;
int n=100;
rc=lrs\u create\u socket(“socket0”、“TCP”、“LocalHost=0”、“RemoteHost=192.168.1.130:10001”、LrsLastArg);
如果(rc=0)
{
lr_结束_事务(“连接插座”,lr_通行证);
返回0;
}
其他的
{
}
//启动事务
lr_启动_事务(“连接插座”);
//检查操作的总运行时间
MasterT=lr_启动_定时器();
//为事务创建一些经过的时间
对于(i=0;i<100;++i)
斯普林特(哥们,
“这是我们人工创建运行时间=%d的方式”,i);
//创建一些浪费的时间并用计时器记录下来
定时器=lr_启动定时器();
对于(i=0;i<100;++i)
斯普林特(哥们,
“这就是我们在脚本中浪费时间的方式=%d”,我);
浪费时间=lr\U end\U定时器(定时器);
lr_输出_消息(“用户创建的浪费时间=%lf”,浪费时间);
lr_输出_消息(“在lr_浪费时间之前:持续时间=%lf-浪费=%lf”,
lr_获取_事务_持续时间(“连接插座”),
lr_获取_事务_浪费时间(“连接插座”);
/*将计时器(以秒为单位)转换为浪费的时间(以毫秒为单位)
并增加内部产生的浪费时间*/
浪费时间*=1000;
lr_浪费时间(wasteTime);
lr\u输出消息(“lr\u浪费时间后:持续时间=%lf-浪费=%lf”,
lr_获取_事务_持续时间(“连接插座”),
lr_获取_事务_浪费时间(“连接插座”);
lr_输出_消息(“思考时间=%lf”,lr_获取_事务_思考时间(“连接套接字”));
lrs_发送(“socket0”、“buf0”、LrsLastArg);
lrs_接收(“socket0”、“buf1”、LrsLastArg);
lrs\u获取上次接收的\u缓冲区(“socket0”、&recvbuf、&recvlen);
lrs_发送(“socket0”、“buf2”、LrsLastArg);
lrs_接收(“插座0”、“buf3”、LrsLastArg);
lrs_发送(“socket0”、“buf4”、LrsLastArg);
lrs_接收(“socket0”、“buf5”、LrsLastArg);
lrs_发送(“socket0”、“buf6”、LrsLastArg);
lrs_接收(“插座0”、“buf7”、LrsLastArg);
lrs_发送(“socket0”、“buf8”、LrsLastArg);
lrs_接收(“插座0”、“buf9”、LrsLastArg);
lr_结束_事务(“连接插座”,lr_自动);
ActualLapsedTime=lr\U end\U定时器(MasterT);
lr_输出_消息(“操作的总运行时间=%lf”,ActualLassedTime);
lrs_闭合_插座(“插座0”);
返回0;
}
或者,在运行测试后,只需对[Event_Meter]表运行一个查询,并将其加入到[Event_Map]表中以获取事务名称。对于事件表中记录的每个事件,都会跟踪浪费的时间和思考时间

lr_set_transaction(
     "foo"
     lr_get_transaction_duration("blahwoof")
          -lr_get_transaction_wasted_time("blahwoof")
          -lr_get_transaction_think_time("blahoof"),
     lr_get_transaction_status("blahwoof")
   ;