|
建议选用:?java vuser
代码编写跟java以一样;
我这边的性能测试,脚本类似这样:
前提:把相应的jar包以来都保存到脚本的根目录下
import lrapi.lr;
import java.util.HashMap;
import java.util.Map;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.tt.marketing.biz.common.IMSEventTaskService;
public class Actions {
ApplicationContext appContext = null;
IMSEventTaskService imsEventTaskService;
Map<String, Map<String, String>> paramsMap;
Map<String, String> userMap;
Map<String, String> actionMap;
int count = 1;
public int init() {
Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
appContext = new ClassPathXmlApplicationContext("imsctu_hsf.xml");
imsEventTaskService = (IMSEventTaskService) appContext
.getBean("imsEventTaskService");
return 0;
}
public int action() {
try{
Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
while(true) {
lr.start_transaction("getData");
// lr.start_transaction("IMS Reality Attach");
// lr.message("init()");
String paramsString = "delay:::1:::::user_nick:::absolutelywuyu:::::user_buyerRate:::15:::::user_userAuthDate:::2009-01-01:::::user_userId:::123456789:::::user_buyerSum:::555:::::user_buyerNum:::555555:::::user_city:::BJ:::::user_mobilePhone:::111:::::user_email:::wuyu@tt.com";
//paramsMap = new HashMap<String, Map<String, String>>();
//userMap = new HashMap<String, String>();
//actionMap = new HashMap<String, String>();
//userMap.put("nick", "jeley_981217");
//userMap.put("userId", "11891");
//userMap.put("buyerRate", "55");
//userMap.put("buyerSum", "5555");
//userMap.put("buyerNum", "555");
//userMap.put("userAuthDate", "2009-01-01");
//userMap.put("email", "performance@taobao.com");
//userMap.put("mobilePhone", "13735838973");
//userMap.put("ip", "144.144.144.144");
//userMap.put("city", "杭州");
//userMap.put("mac", "aa:bb:cc:dd:ee:ff");
//userMap.put("cookie", "domain=testCookie");
//userMap.put("fullname", "系统");
//paramsMap.put("user", userMap);
//actionMap.put("actionId", "1");
// actionMap.put("actionTime", "2009-05-15");
// paramsMap.put("action", actionMap);
imsEventTaskService.sendByString(2924707465960000932L, paramsString);
lr.end_transaction("getData", lr.AUTO);
// lr.end_transaction("IMS sc1", lr.AUTO);
//lr.message("已经发送成功: " + count++);
}
} catch (Exception e) {
lr.error_message(e.getMessage());
lr.end_transaction("getData", lr.FAIL);
}
// return 0;
return 0;
}
public int end() {
return 0;
}
}
谨供参考。
Thanks!
George |
|