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

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

test cleanup

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