The tb tool supports two protocols(json and custom) to benchmark the target tars service. Generally, it is recommended to use the json protocol.
The sample file as follows,Demo.tars:
module tars
{
struct DemoReq
{
0 require string aa;
1 optional int bb;
2 optional vector<byte> cc;
};
struct DemoRsp
{
0 require DemoReq rr;
1 optional bool ok;
};
interface DemoObj
{
int test(int a, int b);
int echo(DemoReq req, out DemoRsp rsp);
};
};
Use the tars2case tool to automatically generate the input file needed by the tb. According to the rpc function of each interface, the tool generates case file and description file, the description file can not be changed.
/usr/local/tars/cpp/tools/tars2case --json Demo.tars --dir=benchmark
cd benchmark && ls
echo.case echo.desc test.case test.desc
After the use case file is automatically generated according to the tars2json tool, the Json content can be modified as needed, in which the structural data of vector and map also can be increased up and down, and the content in vector type can be input in both string and array. Using string, it needs to be converted into bin2hex. In addition, in order to avoid the hot key effect in the benchmark process and prevent the back-end server from falling on the same single machine, tb supports the generation of random content in Number and string in the tars structure in the following two random ways (Value must be string).
Case Content: eg, echo interface
{
"req":"string val",
"bb": "[100-10000]",
"cc": "123456A5B6"
}
./tb -c 600 -s 6000 -D 192.168.31.1 -P 10505 -p json -S tars.DemoServer.DemoObj -M test -C test
json protocol description:
-S Tars servant name
-M Tars interface method
-C(optional) Prefixes for cases and description files, using method names by default
Use the tars2case tool to automatically generate the cases needed by the tb tool. The tars2case tool generates their each case of rpc functions. The values of the parameters can be modified according to the service needs.
/usr/local/tars/cpp/tools/tars2case Demo.tars --dir=benchmark
cd benchmark && ls
echo.case test.case
The case file is divided into upper and lower parts, which are divided by the first line of "#". The upper part is the RPC parameter, and the lower part is the value of the RPC parameter, which corresponds to the parameter one by one.
E.g:
vector<string>|struct<string, int>|map<string, string>
#######
<abc, def, tt, fbb>
<abc, 1>
[abc=def, dfd=bbb]
./tb -c 600 -s 6000 -D 192.168.31.1 -P 10505 -p tars -S tars.DemoServer.DemoObj -M test -C test.txt
custom protocol parameter description
-S Tars servant name
-M Tars interface method
-C Case file,See[Case file generation]和[Modified Cases]
Initiative close: ctrl+C or killall tb,Wait a few seconds and then output the final statistical results.
Passive close: The default duration is 1 hour. After 1 hour, the benchmark tool will bt stopped and the statistical results are output. This time can be adjusted by the-I parameter.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。