一、在springboot项目中设置一个测试样例方法
@RequestMapping(value = "/getParam")
public @ResponseBody
Map<String, String[]> getParam(HttpServletRequest req) throws Exception {
/*Enumeration<String> names = req.getParameterNames();
while(names.hasMoreElements()) {
String name=names.nextElement();
String value = req.getParameter(name);
System.out.println(name+": "+value);
}*/
return req.getParameterMap();
}
二、测试过程
*win+r输入cmd打开命令行,切换到Apache Bench/bin目录下,在F盘新建param.txt用于放置请求字符串,如下:
{"id"="10086","name"="cpx","age"="23"}
*在命令行窗口输入ab命令
ab -n 100000 -c 500 -p F:/ab-gnuplot/param.txt -T application/x-www-form-urlencoded -g F:/ab-gnuplot/param/n100000c500.dat http://localhost:8080/getParam/
*测试结果