Ignore:
Timestamp:
2016-05-12T15:29:56+02:00 (9 years ago)
Author:
Don-vip
Message:

add a performance test for WireframeMapRenderer (same than StyledMapRenderer)

Location:
trunk/test/performance/org/openstreetmap/josm/data/osm/visitor/paint
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/performance/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRendererPerformanceTest.java

    r9773 r10197  
    22package org.openstreetmap.josm.data.osm.visitor.paint;
    33
    4 import java.awt.Color;
    5 import java.awt.Graphics2D;
    6 import java.awt.image.BufferedImage;
    74import java.io.File;
    8 import java.io.FileInputStream;
    95import java.io.IOException;
    10 import java.io.InputStream;
    116
    127import javax.imageio.ImageIO;
    138
    149import org.junit.BeforeClass;
    15 import org.junit.Rule;
    16 import org.junit.Test;
    17 import org.junit.rules.Timeout;
    18 import org.openstreetmap.josm.JOSMFixture;
    19 import org.openstreetmap.josm.Main;
    20 import org.openstreetmap.josm.data.Bounds;
    21 import org.openstreetmap.josm.data.osm.DataSet;
    22 import org.openstreetmap.josm.gui.NavigatableComponent;
    2310import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
    24 import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    25 import org.openstreetmap.josm.io.Compression;
    26 import org.openstreetmap.josm.io.OsmReader;
    2711
    28 public class StyledMapRendererPerformanceTest {
    29 
    30     private static final int IMG_WIDTH = 1400;
    31     private static final int IMG_HEIGHT = 1050;
    32 
    33     private static Graphics2D g;
    34     private static BufferedImage img;
    35     private static NavigatableComponent nc;
    36     private static DataSet dsRestriction;
    37     private static DataSet dsMultipolygon;
    38     private static DataSet dsCity;
    39 
    40     /**
    41      * Global timeout applied to all test methods.
    42      */
    43     @Rule
    44     public Timeout globalTimeout = Timeout.seconds(15*60);
     12/**
     13 * Performance test of {@code StyledMapRenderer}.
     14 */
     15public class StyledMapRendererPerformanceTest extends AbstractMapRendererPerformanceTestParent {
    4516
    4617    @BeforeClass
    4718    public static void load() throws Exception {
    48         JOSMFixture.createPerformanceTestFixture().init(true);
    49         img = new BufferedImage(IMG_WIDTH, IMG_HEIGHT, BufferedImage.TYPE_INT_ARGB);
    50         g = (Graphics2D) img.getGraphics();
    51         g.setClip(0, 0, IMG_WIDTH, IMG_WIDTH);
    52         g.setColor(Color.BLACK);
    53         g.fillRect(0, 0, IMG_WIDTH, IMG_WIDTH);
    54         nc = Main.map.mapView;
    55         nc.setBounds(0, 0, IMG_WIDTH, IMG_HEIGHT);
    56 
     19        AbstractMapRendererPerformanceTestParent.load();
    5720        // TODO Test should have it's own copy of styles because change in style can influence performance
    5821        MapPaintStyles.readFromPreferences();
    59 
    60         try (
    61             InputStream fisR = new FileInputStream("data_nodist/restriction.osm");
    62             InputStream fisM = new FileInputStream("data_nodist/multipolygon.osm");
    63             InputStream fisC = Compression.getUncompressedFileInputStream(new File("data_nodist/neubrandenburg.osm.bz2"));
    64         ) {
    65             dsRestriction = OsmReader.parseDataSet(fisR, NullProgressMonitor.INSTANCE);
    66             dsMultipolygon = OsmReader.parseDataSet(fisM, NullProgressMonitor.INSTANCE);
    67             dsCity = OsmReader.parseDataSet(fisC, NullProgressMonitor.INSTANCE);
    68         }
    6922    }
    7023
    71     private static void test(int iterations, DataSet ds, Bounds bounds) throws Exception {
    72         Rendering visitor = new StyledMapRenderer(g, nc, false);
    73         nc.zoomTo(bounds);
    74         for (int i = 0; i < iterations; i++) {
    75             visitor.render(ds, true, bounds);
    76         }
    77     }
    78 
    79     @Test
    80     public void testRestriction() throws Exception {
    81         test(700, dsRestriction, new Bounds(51.12, 14.147472381591795, 51.128, 14.162492752075195));
    82     }
    83 
    84     @Test
    85     public void testRestrictionSmall() throws Exception {
    86         test(1500, dsRestriction, new Bounds(51.125, 14.147, 51.128, 14.152));
    87     }
    88 
    89     @Test
    90     public void testMultipolygon() throws Exception {
    91         test(400, dsMultipolygon, new Bounds(60, -180, 85, -122));
    92     }
    93 
    94     @Test
    95     public void testMultipolygonSmall() throws Exception {
    96         test(850, dsMultipolygon, new Bounds(-90, -180, 90, 180));
    97     }
    98 
    99     @Test
    100     public void testCity() throws Exception {
    101         test(50, dsCity, new Bounds(53.51, 13.20, 53.59, 13.34));
    102     }
    103 
    104     @Test
    105     public void testCitySmall() throws Exception {
    106         test(70, dsCity, new Bounds(52, 11, 55, 14));
    107     }
    108 
    109     @Test
    110     public void testCityPart1() throws Exception {
    111         test(250, dsCity, new Bounds(53.56, 13.25, 53.57, 13.26));
    112     }
    113 
    114     @Test
    115     public void testCityPart2() throws Exception {
    116         test(200, dsCity, new Bounds(53.55, 13.29, 53.57, 13.30));
    117     }
    118 
    119     @Test
    120     public void testCitySmallPart2() throws Exception {
    121         test(200, dsCity, new Bounds(53.56, 13.295, 53.57, 13.30));
     24    @Override
     25    protected Rendering buildRenderer() {
     26        return new StyledMapRenderer(g, nc, false);
    12227    }
    12328
Note: See TracChangeset for help on using the changeset viewer.