I use StringTemplate to create some XML files from datasets. Sometimes I have over 100,000 records in a dataset that are listed in a template. It goes very slowly (15-20 seconds per operation), so performance is not suitable for me.
This is an example of how I use ST to display a report:
using (var sw = new StringWriter()) { st.Write(new StringTemplateWriter(sw)); return sw.ToString(); }
StringTemplateWriter is a simple writer class derived from IStringTemplateWriter without indentation.
By the way, on the debug screen, I see a lot of such a strange message:
"The first exception of type" antlr.NoViableAltException "exception occurred in StringTemplate.DLL
deep in debugging, I found that it recursively parses my template and if something fails (I donβt know what exactly), it throws a NoViableAltException to return from the depth of the stack back to the surface, so I think the problem is there are too many try-catch-throw's in use.
Google did not find anything useful in this.
The main question: how to reduce this number of exceptions (except for rewriting the ST code) and increase the rendering performance of the template?
source share