Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-3085

Performance regression with MarkupBuilder in 1.6 beta 2

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6-beta-2
    • 1.6-rc-1, 1.7-beta-1
    • None
    • None
    • Ubuntu AMD64 Intel Dual Core 2.4GHz 4Gb RAM . Java 1.6.10 rc 2. Problem occurs both inside IntelliJ IDEA 7.04, and with Ant.

    Description

      Approx time to run script below:

      Groovy 1.5.6 800 ms
      Groovy 1.6 beta1 500 ms
      Groovy 1.6 beta2 1300 ms

      import groovy.xml.MarkupBuilder
      
      class Formatter {
          void formatAsXml(Writer writer) {
              def builder = new MarkupBuilder(writer)
      
              builder.Bookings {
                  Booking {
                      Origin("Auckland")
                      Destination("Wellington")
                      PassengerName("Mr John Smith")
                  }
                  Payment {
                      From("J Smith")
                      Amount(42)
                  }
              }
          }
      }
      
      long start = System.currentTimeMillis()
      def formatter = new Formatter()
      def writer
      1000.times({
          writer = new StringWriter()
          formatter.formatAsXml(writer)
      })
      println "Took ${System.currentTimeMillis() - start} millis"
      
      

      Most of the extra time seems to be in the MarkupBuilder. Replacing formatAsXml() with the following code results in beta 2 being around 10-20% slower than beta 1 (which is within experimental error).

          void formatAsXml(Writer writer) {
              (1..1000).each {
                  writer.write(it)
              }
          }
      

      Attachments

        Activity

          People

            ait Alex Tkachman
            nigel.charman Nigel Charman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: