|
Subject: RE: [xsl] Writing to file vs. storing in a variable From: mjyoungblut@xxxxxxx Date: Wed, 24 Oct 2001 11:51:26 -0500 |
In both of my test cases, I write out the file as an end result. Here are
my steps again:
Approach 1(faster, more memory)
1. Compare the two files and store the results in a variable
2. Use the variable to create a header in output File A
3. Write the contents of the variable to output File A
Approach 2(slower, less memory)
1. Compare the two files, writing the results immediately to File A
2. Read up File A(much smaller than the originals), writing the header to
File B
3. Copy the contents of File A to File B
In my two tests(using Instant Saxon), I run the first approach completely,
and I run only the first step of the second approach.
One thing that I didn't mention in my first email was that as part of step
2 in Approach 1, I get rid of all empty elements and all ancestors of empty
elements. In my Approach 2, I would do this in step 2. Thus, the output
files after step 1 in both approaches will be different in size(Approach 1
is smaller, but not dramatically. Approach 2 results in about 3% of the
original files).
Here is what I am seeing in my mind:
- Both files use ~ same memory to read up and parse the files
- Transform occurs. Approach 1 saves as a variable, so the memory
difference occurs here. Approach 2 writes directly to a file.
- Approach 1 finally writes to a file with less data than Approach 2.
I don't see that extra data as a result of Approach 2, step 1 making the
time consumption being 50% longer.
Any thoughts on this?
Thanks,
Matt
> The problem is that the first part of the second approach
> takes about 50%
> LONGER than all of the steps in the first approach. I have
> tried using
> Saxon and Xalan, and they are pretty equivalent(other than
> Xalan being a
> big memory hog).
>
> Can anybody explain to me why this would be the case?
>
Serialization and parsing are expensive. Instead of using a file as the
intermediate form between two transformations, connect the two
transformations end-to-end as a SAX pipeline, so the nodes produced by the
first are fed straight into the second. Look at the SAXTransformerFactory
class in JAXP.
Mike Kay
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] Writing to file vs. stori, Michael Kay | Thread | [xsl] Creating nodeset for paramete, Hunsberger, Peter |
| Re: [xsl] Conversion from xsl to xs, David Carlisle | Date | Re: [xsl] Conversion from xsl to xs, Tony Graham |
| Month |