You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by polymorphisme <we...@polymorphisme.org> on 2011/08/07 16:49:35 UTC

Re: Performance Analysis

Thank you, Jeremias, the test run fine.


I have a small file.xml and a file xml2fo.xsl to do the transformation xml
--> fo via xsl.

When I test this file file.xml with the FOPBenchmark, 
I obtain a duration of 0,39 seconds! in the results.xml (with the variant
"from-it") :

  <scenario name="xml2fo" variant="from-if">
    <description>Apache FOP: preModel.xml example, rendering from
Intermediate
      Format</description>
    <environment>   
      <value name="java.specification.version">1.6</value>      
    </environment>
    <run idx="0">
      <run>
        <value name="target-format">PDF</value>
        <page-count>2</page-count>
        <duration>390</duration>
        <file mime="application/pdf;mode=painter"
size="24294">file:/C:/Users/greg/workspace/FOPBenchmarks/benchmarks/dev/05/file.if.pdf.if.if.pdf
        </file>
      </run>
    </run>
  </scenario>


So when I take my file.if.xml in my Main class java to do my transformation
if --> pdf.

I can obtain a file.if.pdf (2 pages), also the transformation take 2.4
seconds ! I think it's very a long duration when I see
<duration>390</duration> in my results.xml ! 

Do know why then I use a class java the duration is very long ? 
What can I do for obtain a more small duration ?

Thank you.



My file.if.xml :

<document xmlns="http://xmlgraphics.apache.org/fop/intermediate"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:nav="http://xmlgraphics.apache.org/fop/intermediate/document-navigation">
...
</document>



public class Main {

    public static void main(String[] args) {
  
    	  FopFactory fopFactory = FopFactory.newInstance();

        try {
            long startTime = System.nanoTime();        	   

            File baseDir = new File(".");
            File outDir = new File("out");
            final File xmlfile = new File(baseDir, "xml/file.xml");
            File xsltfile = new File(baseDir, "xsl/xml2fo.xsl");
            File iffile = new File(outDir, "file.if.xml");
            File stampxsltfile = new File(baseDir, "xsl/ifstamp.xsl");
            File pdffile = new File(outDir, "file.if.pdf");                                 
          
            Main app = new Main();

            // Setup output
            OutputStream out = new java.io.FileOutputStream(pdffile);
            out = new java.io.BufferedOutputStream(out);
            
            try {
                FOUserAgent userAgent = fopFactory.newFOUserAgent();

                String mime = MimeConstants.MIME_PDF;
                IFDocumentHandler targetHandler =
fopFactory.getRendererFactory().createDocumentHandler(
                        userAgent, mime);

                IFUtil.setupFonts(targetHandler);
                targetHandler.setResult(new StreamResult(pdffile));

                IFParser parser = new IFParser();

                Source src = new StreamSource(iffile);
                Source xslt = new StreamSource(stampxsltfile);
 
                TransformerFactory tFactory =
TransformerFactory.newInstance();
                Transformer transformer = tFactory.newTransformer(xslt);           

                SAXResult res = new
SAXResult(parser.getContentHandler(targetHandler, userAgent));

                transformer.transform(src, res);
            } finally {
                out.close();
            }            
                                   
            long estimatedTime = System.nanoTime() - startTime;              
            System.out.println("estimatedTime : " + estimatedTime + "\n");
          
        } catch (Exception e) {
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }
}







Jeremias Maerki-2 wrote:
> 
> Well, I did write "FIOY" in the README, so just a few tips so you can
> FIOY:
> 
> - Set debug="true" on the javac tasks. That gives you line numbers in
> the stacktrace and will point you right to the line where the NPE
> happens.
> - Or set up the project in your favourite IDE and set an exception
> breakpoint for NullPointerException.
> 
> Since I don't see any line numbers in the stack trace right now, I can
> only guess. FopReadme.java is not that big and the only place where an
> NPE can happen is at line 34 with the Class.getResource() call. That
> would indicate that "../userconfig-default.xml" can't be found in the
> classpath...... So maybe you forgot to copy a few non-Java files to
> ${build.dest}????????
> 
> On 21.06.2011 10:03:21 polymorphisme wrote:
>> 
>> Hello,
>> 
>> thank you, Jeremias.
>> 
>> For running the test, I have do a file build.xml :
>> 
>>   ... 
>> 
>>   <path id="project-classpath">
>>     <pathelement location="." />
>>     <pathelement location="${build.dest}" />   
>>     <fileset dir="${lib}">
>>       <include name="*.jar"/>
>>     </fileset>                 
>>   </path>
>> 
>>   <target name="build">       
>>     <copy todir="${build.src}">
>>       <fileset dir="${src}"/>
>>     </copy>      
>>     <javac srcdir="${build.src}"
>>        destdir="${build.dest}"
>>        optimize="on"
>>        deprecation="on">
>>       <classpath refid="project-classpath" />    
>>     </javac> 
>>   </target>
>>         
>>   <target name="run" depends="build">
>>     <java classname="org.maerki.benchmark.Main" fork="yes">    
>>       <classpath refid="project-classpath" />    
>>     </java>
>>   </target>
>> 
>>   ...
>> 
>> But the target run return the erreur bellow :
>> 
>> [run]      
>>      [java] BenchmarkRunner starting...
>>      [java] java.specification.version: 1.6
>>      [java] java.vm.name: Java HotSpot(TM) Client VM
>>      [java] java.vm.vendor: Sun Microsystems Inc.
>>      [java] java.vm.version: 14.2-b01
>>      [java] java.lang.NullPointerException
>>      [java] 	at
>> org.maerki.benchmark.examples.fop.readme.FopReadme.<init>(Unknown Source)
>>      [java] 	at
>> org.maerki.benchmark.BenchmarkRunner.addExampleScenarios(Unknown Source)
>>      [java] 	at org.maerki.benchmark.Main.main(Unknown Source)
>>      [java] Java Result: -1
>> BUILD SUCCESSFUL
>> Total time: 2 seconds
>> 
>> I don't know why ! Have you an idee ? Thank at all.
>> 
>> 
>> polymorphisme wrote:
>> > 
>> > Hello,
>> > 
>> > do you know where I can find the program used for the
>> >  http://people.apache.org/~jeremias/fop/benchmark-2009-02-13/
>> Performance
>> > Analysis for Apache FOP's new Intermediate Format  of Jeremias Märki.
>> > 
>> > Thank.
>> > 
>> 
>> -- 
>> View this message in context:
>> http://old.nabble.com/Performance-Analysis-tp31874238p31892115.html
>> Sent from the FOP - Users mailing list archive at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
>> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>> 
> 
> 
> 
> 
> Jeremias Maerki
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Performance-Analysis-tp31874238p32212686.html
Sent from the FOP - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org