[jsword-devel] [JIRA] Commented: (JS-134) JDOM Upgrade and Optimisation

Martin Denham (JIRA) jira at crosswire.org
Tue Nov 30 08:40:37 MST 2010


    [ http://www.crosswire.org/bugs/browse/JS-134?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13586#action_13586 ] 

Martin Denham commented on JS-134:
----------------------------------

My tests utilised ESV Psalm 119.  OSISFilter.parse is called once for  each verse so for Psalm 119 it is called 176 times.  On an Android G1 the number of seconds from the first call of parse() to the last was:
Without change : 6.5 seconds
With change: 5.1 seconds

Not a lot but I thought I would feed it back into JSword.  During my tests I also found that making SAXBuilder an instance variable created in the OSISFilter constructor had no performance benefit.

> JDOM Upgrade and Optimisation
> -----------------------------
>
>                 Key: JS-134
>                 URL: http://www.crosswire.org/bugs/browse/JS-134
>             Project: JSword
>          Issue Type: Improvement
>          Components: o.c.jsword.book.filter.osis
>         Environment: Android
>            Reporter: Martin Denham
>            Assignee: DM Smith
>            Priority: Minor
>
> Only JDOM version 1.1.1 is compatible with Android so in my copy I upgraded JSword's JDOM 1.0 to 1.1.1 which caused no issues because JDOM is so stable and well tested.
> JDOM 1.1.1 also provides a new SAXBuilder flag for faster parsing (see second paragraph of jdom.org) which I think is SAXBuilder.setFastReconfigure() which has this description:
> "Specifies whether this builder will do fast reconfiguration of the underlying SAX parser when reuseParser is true. This improves performance in cases where SAXBuilders are reused and lots of small documents are frequently parsed. This avoids attempting to set features on the SAX parser each time build() is called which result in SaxNotRecognizedExceptions."
> I added this flag to OSISFilter and OSIS parsing was improved by about 20%.  My tests monitored the time from the first OSISFilter.parse() to the last parse() so it is not a 20% improvement on the whole time it takes to show a chapter.
> Here is And Bible's code from OSISFilter with the one line change:
>     private Element parse(String plain) throws JDOMException, IOException {
>         // create a root element to house our document fragment
>         StringReader in = new StringReader("<div>" + plain + "</div>"); //$NON-NLS-1$ //$NON-NLS-2$
>         InputSource is = new InputSource(in);
>         SAXBuilder builder = new SAXBuilder();
>         //MJD START
>         builder.setFastReconfigure(true);
>         //MJD END
>         Document doc = builder.build(is);
>         Element div = doc.getRootElement();
>         return div;
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://www.crosswire.org/bugs/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jsword-devel mailing list