{section}
{column:width=70%}
h2. Java API for KML - Performance
{toc:minLevel=3|maxLevel=5|type=flat}
h3. Performance
Performance measurements were carried out on a 2.66Ghz MacBook Pro with a 1066MHz frontside bus, 4GB (two 2GB SO-DIMMs) of 1066MHz DDR3 SDRAM, and a NVIDIA GeForce 9400M graphics processor with 256MB of DDR3 SDRAM shared with main memory. _JAK_ was tested with Java 1.5 and Java 1.6.
The next listing attempts to be as simple as possible in showing how the performance of _JAK_ was measured. It creates a {{LinerRing}} with N coordinates (N ∈ 1, 5, 10, 50, 100, 500, 1000, 5000, 10000, 50000, 100000, 500000, 1000000, and 5000000). Figure 4.5 1 shows the expansion of the file size. Once using {{Coordinate}}'s {{double}} constructor and once using {{Coordinate}}'s '{{String}}' constructor.
{anchor:listing1}
{code:title=Listing 1: Performance test program. Creates N coordinates. }
// measure _create_ (START)
final Kml kml = new Kml();
final Document document = kml.createAndSetDocument().withName("StressTest");
final Placemark p = document.createAndAddPlacemark().withName(filename);
final LineString ls = p.createAndSetLineString().withTessellate(true);
final List<Coordinate> coords = ls.createAndSetCoordinates();
for (int i = 0; i < N; i++) {
coords.add(new Coordinate ( [double | string ] ));
}
// measure _create_ (STOP)
// measure _marshal_ (START)
kml.marshal(new File("file.kml"), false);
// measure _marshal_ (STOP)
// measure _unmarshal_ (START)
Kml.unmarshal(new File("file.kml "), false);
// measure _unmarshal_ (STOP)
{code}
The test is composed of three different parts with the performance of each part measured separately:
# _create{_}
The object graph with N coordinates is created. The {{Coordinate}} class offers two different kinds of constructors [KML in the Java world#Figure 5|jak:KML in the Java world#figure5]). One constructor takes the coordinate as a string and parses the string internally into latitude, longitude, and altitude as {{double}} values (here called the '{{String}}' constructor). The other constructor takes latitude, longitude, and altitude directly as a {{double}} value; hence, no time consuming parsing is needed (here it is called the '{{double}}' constructor).
For results, see [Figure 2|#figure2].
# _marshal{_}
The object graph with N coordinates is marshalled into a file.
For results, see [Figure 3|#figure3].
# _unmarshal{_}
The file with N coordinates is unmarshalled back into an object graph.
For results, see [Figure 4|#figure4].
The times shown are always the average value taken from three test runs.
{info:title=Annotation}
The horizontal scale of all four figures ([Figure 1|#figure1], [Figure 2|#figure2], [Figure 3|#figure3], and [Figure 4|#figure4]) shown in this chapter is a logarithmic scale. This is helpful whenever the data covers a large range of values because the logarithm reduces the range, making it a more manageable range.
{info}
h3. The size of the output file in megabytes
{anchor:figure1}
!Figure451_the_size_of_the_output_file_in_mb.png!
h6. Figure 1: The size of the output file in megabytes.
h3. Results for part 1 (_create_)
(as seen in [Listing 1|#listing1])
{anchor:figure2}
!Figure452_results_for_create.png!
h6. Figure 2: The fewer seconds needed, the faster the test is. The '{{double}}' constructor is significantly faster than the '{{String}}' constructor. Java 1.6 is approximately twice as fast as Java 1.5 using the '{{String}}' constructor. Java 1.5 and Java 1.6 both have a similar runtime behavior when using the '{{double}}' constructor.
h3. Results for part 2 (_marshal_)
(as seen in [Listing 1|#listing1])
{anchor:figure3}
!Figure453_results_for_marshal.png!
h6. Figure 3: The fewer seconds needed, the faster the test is. Java 1.6 is approximately twice as fast as Java 1.5 at marshalling the object graph into a file.
h3. Results for part 3 (_unmarshal_)
(as seen in [Listing 1|#listing1])
{anchor:figure4}
!Figure454_results_for_unmarshal.png!
h6. Figure 4: The fewer seconds needed, the faster the test is. Java 1.6 is a bit faster than Java 1.5 at unmarshalling a file into an object graph.
{column}
{column:width=1%}
{column}
{column:width=29%}
{livesearch:id=1|spaceKey=jak}
[Java API for KML|Home] | [@Google|http://code.google.com/p/javaapiforkml/]
{pagetree}
{column}
{section}
{column:width=70%}
h2. Java API for KML - Performance
{toc:minLevel=3|maxLevel=5|type=flat}
h3. Performance
Performance measurements were carried out on a 2.66Ghz MacBook Pro with a 1066MHz frontside bus, 4GB (two 2GB SO-DIMMs) of 1066MHz DDR3 SDRAM, and a NVIDIA GeForce 9400M graphics processor with 256MB of DDR3 SDRAM shared with main memory. _JAK_ was tested with Java 1.5 and Java 1.6.
The next listing attempts to be as simple as possible in showing how the performance of _JAK_ was measured. It creates a {{LinerRing}} with N coordinates (N ∈ 1, 5, 10, 50, 100, 500, 1000, 5000, 10000, 50000, 100000, 500000, 1000000, and 5000000). Figure 4.5 1 shows the expansion of the file size. Once using {{Coordinate}}'s {{double}} constructor and once using {{Coordinate}}'s '{{String}}' constructor.
{anchor:listing1}
{code:title=Listing 1: Performance test program. Creates N coordinates. }
// measure _create_ (START)
final Kml kml = new Kml();
final Document document = kml.createAndSetDocument().withName("StressTest");
final Placemark p = document.createAndAddPlacemark().withName(filename);
final LineString ls = p.createAndSetLineString().withTessellate(true);
final List<Coordinate> coords = ls.createAndSetCoordinates();
for (int i = 0; i < N; i++) {
coords.add(new Coordinate ( [double | string ] ));
}
// measure _create_ (STOP)
// measure _marshal_ (START)
kml.marshal(new File("file.kml"), false);
// measure _marshal_ (STOP)
// measure _unmarshal_ (START)
Kml.unmarshal(new File("file.kml "), false);
// measure _unmarshal_ (STOP)
{code}
The test is composed of three different parts with the performance of each part measured separately:
# _create{_}
The object graph with N coordinates is created. The {{Coordinate}} class offers two different kinds of constructors [KML in the Java world#Figure 5|jak:KML in the Java world#figure5]). One constructor takes the coordinate as a string and parses the string internally into latitude, longitude, and altitude as {{double}} values (here called the '{{String}}' constructor). The other constructor takes latitude, longitude, and altitude directly as a {{double}} value; hence, no time consuming parsing is needed (here it is called the '{{double}}' constructor).
For results, see [Figure 2|#figure2].
# _marshal{_}
The object graph with N coordinates is marshalled into a file.
For results, see [Figure 3|#figure3].
# _unmarshal{_}
The file with N coordinates is unmarshalled back into an object graph.
For results, see [Figure 4|#figure4].
The times shown are always the average value taken from three test runs.
{info:title=Annotation}
The horizontal scale of all four figures ([Figure 1|#figure1], [Figure 2|#figure2], [Figure 3|#figure3], and [Figure 4|#figure4]) shown in this chapter is a logarithmic scale. This is helpful whenever the data covers a large range of values because the logarithm reduces the range, making it a more manageable range.
{info}
h3. The size of the output file in megabytes
{anchor:figure1}
!Figure451_the_size_of_the_output_file_in_mb.png!
h6. Figure 1: The size of the output file in megabytes.
h3. Results for part 1 (_create_)
(as seen in [Listing 1|#listing1])
{anchor:figure2}
!Figure452_results_for_create.png!
h6. Figure 2: The fewer seconds needed, the faster the test is. The '{{double}}' constructor is significantly faster than the '{{String}}' constructor. Java 1.6 is approximately twice as fast as Java 1.5 using the '{{String}}' constructor. Java 1.5 and Java 1.6 both have a similar runtime behavior when using the '{{double}}' constructor.
h3. Results for part 2 (_marshal_)
(as seen in [Listing 1|#listing1])
{anchor:figure3}
!Figure453_results_for_marshal.png!
h6. Figure 3: The fewer seconds needed, the faster the test is. Java 1.6 is approximately twice as fast as Java 1.5 at marshalling the object graph into a file.
h3. Results for part 3 (_unmarshal_)
(as seen in [Listing 1|#listing1])
{anchor:figure4}
!Figure454_results_for_unmarshal.png!
h6. Figure 4: The fewer seconds needed, the faster the test is. Java 1.6 is a bit faster than Java 1.5 at unmarshalling a file into an object graph.
{column}
{column:width=1%}
{column}
{column:width=29%}
{livesearch:id=1|spaceKey=jak}
[Java API for KML|Home] | [@Google|http://code.google.com/p/javaapiforkml/]
{pagetree}
{column}
{section}