You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Tom Howard (JIRA)" <ji...@apache.org> on 2017/08/01 09:12:00 UTC

[jira] [Created] (TEXT-99) Performance Degradation for Escaping JSON

Tom Howard created TEXT-99:
------------------------------

             Summary: Performance Degradation for Escaping JSON
                 Key: TEXT-99
                 URL: https://issues.apache.org/jira/browse/TEXT-99
             Project: Commons Text
          Issue Type: Bug
    Affects Versions: 1.1
         Environment: OS X 10.11.6
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
JProfiler 9.1 (Build 9128)
            Reporter: Tom Howard
            Priority: Minor


There seams to be a small performance degradation on StringEscapeUtils.escapeJson(String) in commons-text v1.1 compared to commons-lang3 v3.5

I have a performance test that involves (amongst other things) escaping 200,052 strings. Using commons-text v1.1 this consistently takes 100ms to 110ms. Using commons-lang3 v3.5 this consistently takes 92ms to 95ms.

Also, after escaping I'm writing it to using java.io.Writer.write(String). I would have assumed that StringEscapeUtils.ESCAPE_JSON.translate(CharSequence, writer) would yield better performance, however in the same test, using this method constantly takes approx 210ms and the parent method (which serialises the entire payload to JSON) takes approx 1750ms compared to approx 1400ms using StringEscapeUtils.escapeJson(String) from commons-lang3 v3.5

I've marked the issue as minor, as it doesn't really impact me, but I thought I should share my findings.

The serialiser can be found at https://github.com/mountain-pass/ryvr/blob/master/src/main/java/au/com/mountainpass/ryvr/io/RyvrSerialiser.java and the performance test can be executed using `./gradlew testRyvrTests_Integration_Performance_Java_H2Local`



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)