錄製的功能很簡單,標準的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() 函數的原因。