728x90
@Test void comparePasingTime() throws IOException { String param = "{\"api_name\":\"api\"}"; long before1 = 0; long before2 = 0; long before3 = 0; long before4 = 0; before1 = System.currentTimeMillis(); Map<String, String> pMap = Util.parseJsonString2HashMap4String(param); logger.trace("PARAM VALUE ::: "+ pMap.get("api_name")); logger.trace("MAP PASING INTO MAP WAS TAKING ::: " + (System.currentTimeMillis() - before1)); before2 = System.currentTimeMillis(); JsonPath jsonPath = new JsonPath(param); logger.trace("PARAM VALUE ::: "+ jsonPath.getString("api_name")); logger.trace("JSONPATH PASING INTO MAP WAS TAKING ::: " + (System.currentTimeMillis() - before2)); before3 = System.currentTimeMillis(); JsonObject gsonObject = new JsonParser().parse(param).getAsJsonObject(); logger.trace("PARAM VALUE ::: "+ gsonObject.get("api_name").getAsString()); logger.trace("GSON PASING INTO MAP WAS TAKING ::: " + (System.currentTimeMillis() - before3)); before4 = System.currentTimeMillis(); ObjectMapper mapper = new ObjectMapper(); JsonNode jacsonNode = mapper.readTree(param); logger.trace("PARAM VALUE ::: "+ jacsonNode.get("api_name").asText()); logger.trace("Jackson PASING INTO MAP WAS TAKING ::: " + (System.currentTimeMillis() - before4)); } |
502 [main] TRACE k.c.m.a.t.bithumb.HttpResponseTest - PARAM VALUE ::: api 504 [main] TRACE k.c.m.a.t.bithumb.HttpResponseTest - MAP PASING INTO MAP WAS TAKING ::: 278 1759 [main] TRACE k.c.m.a.t.bithumb.HttpResponseTest - PARAM VALUE ::: api 1759 [main] TRACE k.c.m.a.t.bithumb.HttpResponseTest - JSONPATH PASING INTO MAP WAS TAKING ::: 1255 1792 [main] TRACE k.c.m.a.t.bithumb.HttpResponseTest - PARAM VALUE ::: api 1792 [main] TRACE k.c.m.a.t.bithumb.HttpResponseTest - GSON PASING INTO MAP WAS TAKING ::: 33 1802 [main] TRACE k.c.m.a.t.bithumb.HttpResponseTest - PARAM VALUE ::: api 1802 [main] TRACE k.c.m.a.t.bithumb.HttpResponseTest - Jackson PASING INTO MAP WAS TAKING ::: 10 |
시간비교
파싱 후, 참조 |
비고 |
|||
Map | JsonPath | GSon | Jackson | |
251 | 1263 | - | - | - |
298 | 1306 | - | - | - |
226 | 1107 | - | - | - |
444 | 1232 | 33 | - | - |
240 | 1400 | 24 | 7 |
get |
243 | 1523 | 38 | 15 | |
255 | 1444 | 45 | 13 | |
259 | 1204 | 26 | 10 |
toString |
258 | 1757 | 25 | 9 | |
260 | 1339 | 24 | 8 | |
273 | 1386 | 53 | 43 | - |
278 | 1255 | 33 | 10 | - |
'Dev' 카테고리의 다른 글
스프링 스케쥴러 CRON 식 (0) | 2019.12.11 |
---|---|
인텔리제이 한글 깨짐 :: 같은 것을 다른 방법으로 (0) | 2019.10.18 |
키워드 (0) | 2019.05.28 |
Apache Server에서 TLS 설정 개념잡기 (0) | 2019.03.29 |
리눅스에 Apache / Tomcat (0) | 2019.02.25 |