commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pascal Schumacher (JIRA)" <>
Subject [jira] [Commented] (TEXT-99) Performance Degradation for Escaping JSON
Date Fri, 13 Oct 2017 16:19:00 GMT


Pascal Schumacher commented on TEXT-99:

Thanks for reporting!

I could not find any difference in the implementations that seemed to be the cause of this
regression, so I have no idea how to fix it.

I sadly lack knowledge in this area, so I won't be able to implement the  suggested `
cbuf[], int off, int len)` change.

Pull requests welcome!

> Performance Degradation for Escaping JSON
> -----------------------------------------
>                 Key: TEXT-99
>                 URL:
>             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
>              Labels: escape, json, performance
> 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 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
and the performance test can be executed using `./gradlew testRyvrTests_Integration_Performance_Java_H2Local`
> Also, I should mention that StringEscapeUtils.escapeJson is an order of magnitude faster
than the equivalents from:
> - org.json:json:20170516
> - org.unbescape:unbescape:1.1.5.RELEASE
> - com.googlecode.json-simple:1.1.1
> - net.minidev:son-smart:2.3
> They literally take over 1000ms to do what StringEscapeUtils.escapeJson() does in about
100ms. If there are any other libs you would like me to test against for comparison purposes,
please let me know.

This message was sent by Atlassian JIRA

View raw message