home | career | drupal | java | mac | mysql | perl | scala | uml | unix

Groovy example source code file (BuilderPerfTest.groovy)

This example Groovy source code file (BuilderPerfTest.groovy) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Groovy tags/keywords

amount, booking, destination, destination, groovytestcase, j, john, markupbuilder, passengername, smith, smith, stringwriter, stringwriter, took

The Groovy BuilderPerfTest.groovy source code

import groovy.xml.MarkupBuilder

class BuilderPerfTest extends GroovyTestCase {
    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)
            }
        }
    }

    void testMe () {
        long start = System.currentTimeMillis()
        def writer
        5000.times({
            writer = new StringWriter()
            formatAsXml(writer)
        })
        println "Took ${System.currentTimeMillis() - start} millis"
    }
}

Other Groovy examples (source code examples)

Here is a short list of links related to this Groovy BuilderPerfTest.groovy source code file:

new blog posts

 

Copyright 1998-2013 Alvin Alexander, alvinalexander.com
All Rights Reserved.