gpt4 book ai didi

c - LR Merc_timer_handle_t

转载 作者:行者123 更新时间:2023-11-30 17:40:04 32 4
gpt4 key购买 nike

我想使用“merc_timer_handle_t”来记录loadrunner中的时间,但是当我创建场景时,LR给出错误消息:“第15行靠近“MasterT”的语法错误” .

我想知道如何使用“merc_timer_handle_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;
}

最佳答案

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")
;

或者,运行测试后,只需对 [Event_Meter] 表运行查询,并连接到 [Event_Map] 表以获取事务名称。事件计量表中跟踪每个记录事件的浪费时间和思考时间

关于c - LR Merc_timer_handle_t,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21621393/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com