录制的功能很简单,标准的GIS项目业务操作“连接数据库”——“放大”( zoom out)。操作过程很顺利,并且时间也很短。但脚本回放和场景运行时都发生了等待时间较长的情况,最后运行结果显示事件消耗时间却很短,即:事件消耗时间正常。也就是说,这个录制脚本出了问题。重新回放脚本,在Replay Log中频繁出现【Mismatch】提示:
Action.c: lrs_receive(socket0, buf3)
Action.c: Mismatch (expected 236 bytes, 212 bytes actually received)
这是因为脚本在回放时,会动态的进行数据匹配,将录制时receive的buf数据与回放时receive的buf数据进行比较,如果字节不匹配则进行等待。因socket脚本内容冗长,这样等待会延长脚本的回放时间,从而影响我们的工作效率,所以我们要为socket接收预期数据设置一个超时时间。
void lrs_set_recv_timeout(long sec, long u_sec); // 设置接收数据的等待时间(超时时间)
sec:The desired timeout in seconds. (default:10 second) // 设置超时时间“秒”
u_sec:The desired timeout in microseconds.(which is added to the sec parameter) // 设置超时时间“微秒”
void lrs_set_recv_timeout2(long sec, long u_sec); // 设置建立连接成功之后,接收数据的等待时间。
Example1:
lrs_create_socket("socket2", "TCP", "RemoteHost=tears.mercury.co.il:23", LrsLastArg);
lrs_send("socket2", "buf2", LrsLastArg);
lrs_set_recv_timeout(120,0);
lrs_set_recv_timeout2(10,0);
lrs_receive("socket2", "buf3", LrsLastArg);
Example2:
Action()
{
double Connect_trans_time;
double Move_trans_time;
//lrs_set_recv_timeout2(1,1); // 参数为 long 型
lr_start_transaction("Connect");
lrs_create_socket("socket0", "TCP", "RemoteHost=172.20.2.5:5151", LrsLastArg);
lrs_send("socket0", "buf0", LrsLastArg);
终于搞定了ANMap无法录制的问题,但是在场景运行之后无法记录“吞吐量”数据。
最后发现是脚本中添加了 lrs_set_recv_timeout() 函数的原因。