代码拉取完成,页面将自动刷新
@TOC
首先说说Gson和Fastjson的相关使用,详细博文 链接点我
都说FastJson更快,为什么那么快呢,已有许多博文解析,比如 链接点我
全部 代码地址
Student student = initStudent();
String json = "";
long time0;
time0 = SystemClock.elapsedRealtime();
for (int i = 0; i < FOR_NUM; i++) {
// gson = new Gson();
json = gson.toJson(student);
}
Log.d(TAG, "Gson Object to json time:" + (SystemClock.elapsedRealtime() - time0));
//Log.d(TAG, "Gson Object to json :" + json);
time0 = SystemClock.elapsedRealtime();
for (int i = 0; i < FOR_NUM; i++) {
// gson = new Gson();
student = gson.fromJson(json, Student.class);
}
Log.d(TAG, "Gson json to Object time:" + (SystemClock.elapsedRealtime() - time0));
time0 = SystemClock.elapsedRealtime();
for (int i = 0; i < FOR_NUM; i++) {
json = JSON.toJSONString(student);
}
Log.d(TAG, "JSON Object to json time:" + (SystemClock.elapsedRealtime() - time0));
// Log.d(TAG, "JSON Object to json :" + json);
time0 = SystemClock.elapsedRealtime();
for (int i = 0; i < FOR_NUM; i++) {
student = JSON.parseObject(json, Student.class);
}
Log.d(TAG, "JSON json to Object time:" + (SystemClock.elapsedRealtime() - time0));
//Log.d(TAG, "result:" + JSON.toJSONString(student));
05-06 14:05:28.261 19015 19126 D GsonFastjson: Gson Object to json time:225
05-06 14:05:28.473 19015 19126 D GsonFastjson: Gson json to Object time:211
05-06 14:05:28.648 19015 19126 D GsonFastjson: JSON Object to json time:176
05-06 14:05:28.927 19015 19126 D GsonFastjson: JSON json to Object time:279
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型