source: josm/trunk/test/performance/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRendererPerformanceTest.java@ 8510

Last change on this file since 8510 was 8510, checked in by Don-vip, 9 years ago

checkstyle: enable relevant whitespace checks and fix them

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/plain
File size: 3.7 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.osm.visitor.paint;
3
4import java.awt.Graphics2D;
5import java.awt.image.BufferedImage;
6import java.io.File;
7import java.io.FileInputStream;
8import java.io.InputStream;
9
10import org.junit.BeforeClass;
11import org.junit.Test;
12import org.openstreetmap.josm.JOSMFixture;
13import org.openstreetmap.josm.data.Bounds;
14import org.openstreetmap.josm.data.osm.DataSet;
15import org.openstreetmap.josm.gui.NavigatableComponent;
16import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
17import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
18import org.openstreetmap.josm.io.Compression;
19import org.openstreetmap.josm.io.OsmReader;
20
21public class StyledMapRendererPerformanceTest {
22
23 private static final int IMG_WIDTH = 1400;
24 private static final int IMG_HEIGHT = 1050;
25
26 private static Graphics2D g;
27 private static BufferedImage img;
28 private static NavigatableComponent nc;
29 private static DataSet dsRestriction;
30 private static DataSet dsMultipolygon;
31 private static DataSet dsCity;
32
33 @BeforeClass
34 public static void load() throws Exception {
35 JOSMFixture.createPerformanceTestFixture().init();
36 img = new BufferedImage(IMG_WIDTH, IMG_HEIGHT, BufferedImage.TYPE_3BYTE_BGR);
37 g = (Graphics2D) img.getGraphics();
38 nc = new NavigatableComponent();
39 nc.setBounds(0, 0, IMG_WIDTH, IMG_HEIGHT);
40
41 // TODO Test should have it's own copy of styles because change in style can influence performance
42 MapPaintStyles.readFromPreferences();
43
44 try (
45 InputStream fisR = new FileInputStream("data_nodist/restriction.osm");
46 InputStream fisM = new FileInputStream("data_nodist/multipolygon.osm");
47 InputStream fisC = Compression.getUncompressedFileInputStream(new File("data_nodist/neubrandenburg.osm.bz2"));
48 ) {
49 dsRestriction = OsmReader.parseDataSet(fisR, NullProgressMonitor.INSTANCE);
50 dsMultipolygon = OsmReader.parseDataSet(fisM, NullProgressMonitor.INSTANCE);
51 dsCity = OsmReader.parseDataSet(fisC, NullProgressMonitor.INSTANCE);
52 }
53 }
54
55 private static void test(int iterations, DataSet ds, Bounds bounds) throws Exception {
56 Rendering visitor = new StyledMapRenderer(g, nc, false);
57 nc.zoomTo(bounds);
58 for (int i = 0; i < iterations; i++) {
59 visitor.render(ds, true, bounds);
60 }
61 }
62
63 @Test
64 public void testRestriction() throws Exception {
65 test(700, dsRestriction, new Bounds(51.12, 14.147472381591795, 51.128, 14.162492752075195));
66 }
67
68 @Test
69 public void testRestrictionSmall() throws Exception {
70 test(1500, dsRestriction, new Bounds(51.125, 14.147, 51.128, 14.152));
71 }
72
73 @Test
74 public void testMultipolygon() throws Exception {
75 test(400, dsMultipolygon, new Bounds(60, -180, 85, -122));
76 }
77
78 @Test
79 public void testMultipolygonSmall() throws Exception {
80 test(850, dsMultipolygon, new Bounds(-90, -180, 90, 180));
81 }
82
83 @Test
84 public void testCity() throws Exception {
85 test(50, dsCity, new Bounds(53.51, 13.20, 53.59, 13.34));
86 }
87
88 @Test
89 public void testCitySmall() throws Exception {
90 test(70, dsCity, new Bounds(52, 11, 55, 14));
91 }
92
93 @Test
94 public void testCityPart1() throws Exception {
95 test(250, dsCity, new Bounds(53.56, 13.25, 53.57, 13.26));
96 }
97
98 @Test
99 public void testCityPart2() throws Exception {
100 test(200, dsCity, new Bounds(53.55, 13.29, 53.57, 13.30));
101 }
102
103 @Test
104 public void testCitySmallPart2() throws Exception {
105 test(200, dsCity, new Bounds(53.56, 13.295, 53.57, 13.30));
106 }
107}
Note: See TracBrowser for help on using the repository browser.