Loading ...
Sorry, an error occurred while loading the content.

difference in times

Expand Messages
  • Danelaw
    i need to reduce the times in fop principally the first times, why the first time it uses one xml and xslt is more slow than others? if i made the transform in
    Message 1 of 7 , Dec 1, 2005
    • 0 Attachment
      i need to reduce the times in fop
      principally the first times, why the first time it uses one xml and xslt is
      more slow than others?

      if i made the transform in pdf with xml and xslt

      through these

      public String transformar (String msgText ,String xsltfile) {
      org.apache.fop.configuration.Configuration.put
      ("baseDir","/informes");
      File fileopt = new File("/informes/userconfig.xml");
      try {
      Options opt = new Options(fileopt);
      }catch (Exception e) {

      }


      xsltfile=Configuracion.get("caminoInformes")+xsltfile;
      Source xsltSource = new StreamSource(xsltfile);
      TransformerFactory transFact = TransformerFactory.newInstance();
      try {
      Templates cachedXSLT = transFact.newTemplates(xsltSource);
      Transformer trans = cachedXSLT.newTransformer();
      long ti1 = System.currentTimeMillis();
      Driver driver = new Driver();
      driver.setRenderer(Driver.RENDER_PDF);
      long ti2 = System.currentTimeMillis();
      System.out.println("t111:"+(ti2-ti1));


      long tiempo1 = System.currentTimeMillis();
      //File filePfXSL = new File (xsltfile);


      long random = System.currentTimeMillis();

      String pdffile = "/tmp/generado"+ random +".pdf";
      long tiempo2=0;
      // Construct fop with desired output format
      // Setup output
      try {
      OutputStream out = new java.io.FileOutputStream
      (pdffile);
      out = new java.io.BufferedOutputStream(out);

      try {

      driver.setOutputStream(out);


      trans.setParameter("versionParam", "2.0");
      String cadena2="";
      int inicio = 0;
      String xml = msgText;

      Source src = new StreamSource(new
      StringReader(xmlBueno));
      //String xsltfile = xslt;
      // Resulting SAX events (the generated FO) must be
      piped through to FOP
      long ti5 = System.currentTimeMillis();
      Result res = new SAXResult(driver.getContentHandler
      ());

      // Start XSLT transformation and FOP processing
      trans.transform(src, res);
      tiempo2 = System.currentTimeMillis();
      depura("Success!");
      System.out.println("tiempo
      transform:"+(tiempo2-ti5));
      } catch (TransformerException e) {
      logger.warn("Error generando pdf :"+e.getMessage());

      } catch (SAXException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      } finally {
      out.close();
      }
      System.out.println(tiempo1);
      System.out.println(tiempo2);
      System.out.println("Total:" + (tiempo2-tiempo1));
      logger.info("Tiempo 1:" + tiempo1);
      logger.info("Tiempo 2:" + tiempo2);
      logger.info("Total :" + (tiempo2-tiempo1));
      return pdffile;
      }catch (FileNotFoundException e){
      e.printStackTrace();
      return null;
      } catch (IOException e) {
      logger.debug("Error cerrando el fichero
      "+e.getMessage());


      } }catch (Exception e) {//del primero el de arriba del todo
      e.printStackTrace();
      }
      return null;


      }



      the first time i execute the program is always more time than others (2
      times or less )

      example:

      in the same program
      main () {
      transformar(msg,xslt);

      transformar(msg,xslt);
      transformar(msg,xslt);
      }

      times are more or less
      t1:6987
      t2:3567
      t3:2998


      can someone tell me how to reduce the first time? because the xml can
      change, but i can preload? the xslt or something

      any help?

      thank you


      [Non-text portions of this message have been removed]
    • J.Pietschmann
      ... It depends what you mean by first time . First run after JVM startup - the usual JVM warmup time. First time using a new XSLT - maybe reading and
      Message 2 of 7 , Dec 1, 2005
      • 0 Attachment
        Danelaw wrote:
        > principally the first times, why the first time it uses one xml and xslt is
        > more slow than others?

        It depends what you mean by "first time".
        First run after JVM startup -> the usual JVM warmup time.
        First time using a new XSLT -> maybe reading and compiling the style
        sheet, although this should be insignificant for most style sheets
        and XSLT processors in practical use.
        There are half a zillion more possible reasons, down to the OS file
        cache and swapping out other applications.

        J.Pietschmann
      • J.Pietschmann
        ... xslt is ... It depends what you mean by first time . First run after JVM startup - the usual JVM warmup time. First time using a new XSLT - maybe
        Message 3 of 7 , Dec 1, 2005
        • 0 Attachment
          Danelaw wrote:
          > principally the first times, why the first time it uses one xml and
          xslt is
          > more slow than others?

          It depends what you mean by "first time".
          First run after JVM startup -> the usual JVM warmup time.
          First time using a new XSLT -> maybe reading and compiling the style
          sheet, although this should be insignificant for most style sheets
          and XSLT processors in practical use.
          There are half a zillion more possible reasons, down to the OS file
          cache and swapping out other applications.

          J.Pietschmann
        • Danelaw
          is the first time it uses a xslt how can time be reduced? using another parser? many thx for the response ... [Non-text portions of this message have been
          Message 4 of 7 , Dec 1, 2005
          • 0 Attachment
            is the first time it uses a xslt
            how can time be reduced? using another parser?


            many thx for the response
            On 12/1/05, J.Pietschmann <j3322ptm@...> wrote:
            >
            > Danelaw wrote:
            > > principally the first times, why the first time it uses one xml and
            > xslt is
            > > more slow than others?
            >
            > It depends what you mean by "first time".
            > First run after JVM startup -> the usual JVM warmup time.
            > First time using a new XSLT -> maybe reading and compiling the style
            > sheet, although this should be insignificant for most style sheets
            > and XSLT processors in practical use.
            > There are half a zillion more possible reasons, down to the OS file
            > cache and swapping out other applications.
            >
            > J.Pietschmann
            >
            >
            >
            >
            > Yahoo! Groups Links
            >
            >
            >
            >
            >
            >
            >


            [Non-text portions of this message have been removed]
          • J.Pietschmann
            ... Parser??? Unless your style sheet approaches the size of 1MB the parser should be really irrelevant. What XSLT processor are you using? How
            Message 5 of 7 , Dec 1, 2005
            • 0 Attachment
              Danelaw wrote:
              > is the first time it uses a xslt
              > how can time be reduced? using another parser?

              Parser??? Unless your style sheet approaches the size of 1MB the
              parser should be really irrelevant. What XSLT processor are you
              using? How large/complicated is the style sheet? Do you use
              xsl:include/xsl:import on a large scale? Are you sure you don't
              confuse this with the JVM warmup/class loading time?
            • Danelaw
              it is not the warm time of the jvm because if i use another xslt after the first time the times are more or less the same gen.transformar(msg1,xslt1);
              Message 6 of 7 , Dec 2, 2005
              • 0 Attachment
                it is not the warm time of the jvm because if i use another xslt after the
                first time the times are more or less the same
                gen.transformar(msg1,xslt1);
                gen.transformar(msg1,xslt1);
                gen.transformar(msg1,xslt1);
                gen.transformar(msg2,xslt2);
                gen.transformar(msg2,xslt2);
                gen.transformar(msg2,xslt2);
                the times are
                6852
                1856
                1571

                6923
                2152
                1999

                and these are more one of the xsl


                On 12/2/05, J.Pietschmann <j3322ptm@...> wrote:
                >
                > Danelaw wrote:
                > > is the first time it uses a xslt
                > > how can time be reduced? using another parser?
                >
                > Parser??? Unless your style sheet approaches the size of 1MB the
                > parser should be really irrelevant. What XSLT processor are you
                > using? How large/complicated is the style sheet? Do you use
                > xsl:include/xsl:import on a large scale? Are you sure you don't
                > confuse this with the JVM warmup/class loading time?
                >
                >
                >
                >
                > Yahoo! Groups Links
                >
                >
                >
                >
                >
                >
                >


                [Non-text portions of this message have been removed]
              • J.Pietschmann
                ... Given that you don t even cache the XSLT Templates object, I d say the difference is probably loading new classes and perhaps other low level caching
                Message 7 of 7 , Dec 3, 2005
                • 0 Attachment
                  Danelaw wrote:
                  > it is not the warm time of the jvm because if i use another xslt after the
                  > first time the times are more or less the same
                  > gen.transformar(msg1,xslt1);
                  > gen.transformar(msg1,xslt1);
                  > gen.transformar(msg1,xslt1);
                  > gen.transformar(msg2,xslt2);
                  > gen.transformar(msg2,xslt2);
                  > gen.transformar(msg2,xslt2);
                  > the times are
                  > 6852
                  > 1856
                  > 1571
                  >
                  > 6923
                  > 2152
                  > 1999
                  >
                  > and these are more one of the xsl


                  Given that you don't even cache the XSLT Templates object, I'd
                  say the difference is probably loading new classes and perhaps
                  other low level caching effects. I don't think there is much you
                  can do about this, except perhaps doing a detailed profiling (using
                  a real Java profiler).
                  And you *should* try to write less confusing code.

                  J.Pietschmann
                Your message has been successfully submitted and would be delivered to recipients shortly.