org.json和json_simple-1.1性能测试
2010-09-02 17:01
776 查看
org.json和json_simple-1.1性能测试
测试方法:
//org.json
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
long in = Calendar.getInstance().getTimeInMillis();
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String reason = request.getParameter("reason");
try {
for (int i = 0; i < 1000; i++) {
JSONObject results = new JSONObject();
results.put("isSuccess", true);
results.put("reason", reason);
JSONObject r = new JSONObject(results.toString());
out.println(r.toString());
}
out.println(Calendar.getInstance().getTimeInMillis() - in);
out.close();
} catch (JSONException e) {
e.printStackTrace();
}
}
//json_simple-1.1
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
long in = Calendar.getInstance().getTimeInMillis();
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String reason = request.getParameter("reason");
for (int i = 0; i < 1000; i++) {
JSONObject results = new JSONObject();
results.put("isSuccess", true);
results.put("reason", reason);
JSONObject r = (JSONObject) JSONValue.parse(results.toString());
out.println(r.toString());
}
out.println(Calendar.getInstance().getTimeInMillis() - in);
out.close();
}
测试结果:org.json输入10次,反应时间【16,31,31,31,31,31,31,32,32,31】
json_simple-1.1输入10次,反应时间【47,62,62,62,78,79,78,62,79,63】
测试结论:每次输入的reason参数都不一样,可以得出org.json性能在某些方面超过 json_simple
测试方法:
//org.json
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
long in = Calendar.getInstance().getTimeInMillis();
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String reason = request.getParameter("reason");
try {
for (int i = 0; i < 1000; i++) {
JSONObject results = new JSONObject();
results.put("isSuccess", true);
results.put("reason", reason);
JSONObject r = new JSONObject(results.toString());
out.println(r.toString());
}
out.println(Calendar.getInstance().getTimeInMillis() - in);
out.close();
} catch (JSONException e) {
e.printStackTrace();
}
}
//json_simple-1.1
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
long in = Calendar.getInstance().getTimeInMillis();
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String reason = request.getParameter("reason");
for (int i = 0; i < 1000; i++) {
JSONObject results = new JSONObject();
results.put("isSuccess", true);
results.put("reason", reason);
JSONObject r = (JSONObject) JSONValue.parse(results.toString());
out.println(r.toString());
}
out.println(Calendar.getInstance().getTimeInMillis() - in);
out.close();
}
测试结果:org.json输入10次,反应时间【16,31,31,31,31,31,31,32,32,31】
json_simple-1.1输入10次,反应时间【47,62,62,62,78,79,78,62,79,63】
测试结论:每次输入的reason参数都不一样,可以得出org.json性能在某些方面超过 json_simple
相关文章推荐
- python JSON性能测试与simplejson对比
- python JSON性能测试与simplejson对比
- org.json与fastjson与gson的倾向于解析速度的性能测试
- Java 下的 JSON库性能比较:JSON.simple vs. GSON vs. Jackson vs. JSONP
- 介绍4款json的java类库 及 其性能测试
- Json学习总结(2)——Java 下的 JSON库性能比较:JSON.simple vs. GSON vs. Jackson vs. JSONP
- json性能测试
- org.json.simple使用详解
- Gson 和 FastJson 性能测试
- Json性能测试——cJSON vs rapidjson
- Json学习总结(2)——Java 下的 JSON库性能比较:JSON.simple vs. GSON vs. Jackson vs. JSONP
- 几种常用JSON库的性能测试。
- JSON性能测试
- PHP中json_encode、json_decode与serialize、unserialize的性能测试分析
- FastJSON、Gson、Jackson和Json-lib性能测试
- 两款JSON类库Jackson与JSON-lib的性能对比(新增第三款测试)
- Java 下的 JSON库性能比较:JSON.simple vs. GSON vs. Jackson vs. JSONP
- php的serialize序列化和json性能测试
- JSON库之性能比较:JSON.simple VS GSON VS Jackson VS JSONP
- org.json.simple使用详解