Brian Frutchey wrote:
I am writing a JNI bridge which uses Xalan-C++ to speed up the XSLT
processing in a Java application. Everything is functional, but the
XalanTransformer.transform method is perform exceptionally slow (slower
than a native Java implementation using Xalan-J). Strangely, I am
copying the code from the XalanTransformer sample project, but when I
use the packaged executable from the command line on the same file and
stylesheet the performance is lightning fast.
Do you mean the XalanTransformer sample application, or the Xalan
executable?
The only major difference between my code and the sample project is
that instead of compiling as an executable I am compiling as a DLL.
Could this be the source of my performance hit? My DLL will convert a
1MB file in 44secs, the executable takes about .2secs. What else
might it be?
Are you testing this outside of the Java environment, to make sure
nothing in Java is taking up the time? Building into a DLL should not
have any effect on performance.
Code:
...
XALAN_USING_STD(istrstream)
XALAN_USING_STD(ostringstream)
Using std::ostringstream or std::ostrstream is never a good idea if you
want the best performance. Take a look at the XalanTransformerCallback
sample to see how you can use the callback mechanism to avoid multiple
memory allocations and extra copies of the serialized result.
If you're having performance problems, I suggest you do the following:
1. Make sure you are building a release DLL and the compiler is set to
optimize.
2. Use a callback to avoid extraneous memory allocations and extra
copies of the data.
3. Test your code without any JNI artifacts, to verify the performance
problem is actually related to Xalan and your code that works with
Xalan, and not JNI.
This email message and any attachments are confidential to Endeca. If
you are not the intended recipient, please notify Endeca immediately --
by replying to this message or by sending an email to: [EMAIL PROTECTED]
-- and destroy all copies of this message and any attachments. Thank you.
You should remove this tag from your postings to public mailing lists,
since your message is _not_ confidential in the least.
Dave