ICE接口性能太好了,用Ruby写的RoadRunner压不起来,估计改成进程方式会好很多。
用LR+DLL这个方法是很可行的。
Init
int id, scid;
char *vuser_group;
vuser_init()
{
lr_whoami(&id, &vuser_group, &scid);
srand(id*scid*time());
lr_load_dll("iceclient_stresstest.dll");
Initialize("userService:default -h 10.2.224.242 -p 10002",1);
return 0;
}
char params[1024];
int rt = 0;
char longId[32];
char nickname[32];
Action()
{
sprintf(nickname,"memUdb_%dx%dx%d",rand()%1000,rand()%1000,rand()%1000);
switch(rand()%3){
case 0:
sprintf(longId,"cntaobao%s",nickname);
break;
case 1:
sprintf(longId,"cnalichn%s",nickname);
break;
case 2:
sprintf(longId,"wangwang%s",nickname);
}
lr_save_string(nickname,"nickname");
lr_save_string(longId,"longId");
memset(params,0,1024);
strcat(params,lr_eval_string("<?xml version=\"1.0\" encoding=\"gb2312\"?>"));
strcat(params,lr_eval_string("<ICEPrx>"));
strcat(params,lr_eval_string("<Case>"));
strcat(params,lr_eval_string("<Param name=\"registerInfo\" type =\"Sequence\">"));
strcat(params,lr_eval_string("<Param name=\"content\">"));
strcat(params,lr_eval_string("<Param name=\"key\" type=\" ::std::string\">longId</Param>"));
strcat(params,lr_eval_string("<Param name=\"value\" type=\"::std::string\">{longId}</Param>"));
strcat(params,lr_eval_string("</Param>"));
strcat(params,lr_eval_string("<Param name=\"content\">"));
strcat(params,lr_eval_string("<Param name=\"key\" type=\" ::std::string\">userId</Param>"));
strcat(params,lr_eval_string("<Param name=\"value\" type=\"::std::string\"></Param>"));
strcat(params,lr_eval_string("</Param>"));
strcat(params,lr_eval_string("<Param name=\"content\">"));
strcat(params,lr_eval_string("<Param name=\"key\" type=\" ::std::string\">nickname</Param>"));
strcat(params,lr_eval_string("<Param name=\"value\" type=\"::std::string\">{nickname}</Param>"));
strcat(params,lr_eval_string("</Param>"));
strcat(params,lr_eval_string("<Param name=\"content\">"));
strcat(params,lr_eval_string("<Param name=\"key\" type=\" ::std::string\">password</Param>"));
strcat(params,lr_eval_string("<Param name=\"value\" type=\"::std::string\">111111</Param>"));
strcat(params,lr_eval_string("</Param>"));
strcat(params,lr_eval_string("<Param name=\"content\">"));
strcat(params,lr_eval_string("<Param name=\"key\" type=\" ::std::string\">email</Param>"));
strcat(params,lr_eval_string("<Param name=\"value\" type=\"::std::string\">{nickname}@alibaba.com</Param>"));
strcat(params,lr_eval_string("</Param>"));
strcat(params,lr_eval_string("</Param>"));
strcat(params,lr_eval_string("</Case>"));
strcat(params,lr_eval_string("</ICEPrx>"));
lr_start_transaction("LoadFunc");
rt = LoadFunc(params);
lr_output_message("rt = %d",rt);
if(rt == -1|| rt == -2){
lr_end_transaction("LoadFunc", LR_FAIL);
}
lr_end_transaction("LoadFunc", LR_AUTO);
return 0;
}
vuser_end()
{
return 0;
}