Changeset 17615 in josm for trunk/test/performance


Ignore:
Timestamp:
2021-03-21T13:56:13+01:00 (4 years ago)
Author:
simon04
Message:

see #4626 - Extract PerformanceTestUtils.getNeubrandenburgDataSet

Location:
trunk/test/performance/org/openstreetmap/josm
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/performance/org/openstreetmap/josm/PerformanceTestUtils.java

    r11324 r17615  
    22package org.openstreetmap.josm;
    33
     4import java.io.File;
     5import java.io.IOException;
     6import java.io.InputStream;
    47import java.util.ArrayList;
    58import java.util.Collections;
    69
     10import org.openstreetmap.josm.data.osm.DataSet;
     11import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
     12import org.openstreetmap.josm.io.Compression;
     13import org.openstreetmap.josm.io.IllegalDataException;
     14import org.openstreetmap.josm.io.OsmReader;
    715import org.openstreetmap.josm.io.XmlWriter;
    816
     
    1422 */
    1523public final class PerformanceTestUtils {
     24    /**
     25     * The Neubrandenburg data file
     26     */
     27    public static final String DATA_FILE = "nodist/data/neubrandenburg.osm.bz2";
    1628    private static final int TIMES_WARMUP = 2;
    1729    private static final int TIMES_RUN = 8;
     30
     31    /**
     32     * Parses and returns the Neubrandenburg dataset
     33     * @return the Neubrandenburg dataset
     34     * @throws IllegalDataException in case of invalid data
     35     * @throws IOException in case of I/O error
     36     */
     37    public static DataSet getNeubrandenburgDataSet() throws IOException, IllegalDataException {
     38        try (InputStream in = Compression.getUncompressedFileInputStream(new File(DATA_FILE))) {
     39            return OsmReader.parseDataSet(in, NullProgressMonitor.INSTANCE);
     40        }
     41    }
    1842
    1943    /**
  • trunk/test/performance/org/openstreetmap/josm/data/osm/visitor/paint/AbstractMapRendererPerformanceTestParent.java

    r17275 r17615  
    1818import org.junit.jupiter.api.Timeout;
    1919import org.openstreetmap.josm.JOSMFixture;
     20import org.openstreetmap.josm.PerformanceTestUtils;
    2021import org.openstreetmap.josm.data.Bounds;
    2122import org.openstreetmap.josm.data.osm.DataSet;
     
    7576        StyledMapRenderer.PREFERENCE_TEXT_ANTIALIASING.put("gasp");
    7677
     78        dsCity = PerformanceTestUtils.getNeubrandenburgDataSet();
    7779        try (InputStream fisR = Files.newInputStream(Paths.get("nodist/data/restriction.osm"));
    7880             InputStream fisM = Files.newInputStream(Paths.get("nodist/data/multipolygon.osm"));
    79              InputStream fisC = Compression.getUncompressedFileInputStream(new File("nodist/data/neubrandenburg.osm.bz2"));
    8081             InputStream fisO = Compression.getUncompressedFileInputStream(new File("nodist/data/overpass-download.osm.bz2"));) {
    8182            dsRestriction = OsmReader.parseDataSet(fisR, NullProgressMonitor.INSTANCE);
    8283            dsMultipolygon = OsmReader.parseDataSet(fisM, NullProgressMonitor.INSTANCE);
    83             dsCity = OsmReader.parseDataSet(fisC, NullProgressMonitor.INSTANCE);
    8484            dsOverpass = OsmReader.parseDataSet(fisO, NullProgressMonitor.INSTANCE);
    8585        }
  • trunk/test/performance/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerPerformanceTest.java

    r17588 r17615  
    66import org.junit.jupiter.api.Test;
    77import org.junit.jupiter.api.extension.RegisterExtension;
     8import org.openstreetmap.josm.PerformanceTestUtils;
    89import org.openstreetmap.josm.data.osm.DataSet;
    9 import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    10 import org.openstreetmap.josm.io.Compression;
    11 import org.openstreetmap.josm.io.OsmReader;
    1210import org.openstreetmap.josm.testutils.JOSMTestRules;
    13 
    14 import java.io.File;
    15 import java.io.InputStream;
    1611
    1712/**
     
    3934        tagChecker = new MapCSSTagChecker();
    4035        tagChecker.initialize();
    41         try (InputStream in = Compression.getUncompressedFileInputStream(new File("nodist/data/neubrandenburg.osm.bz2"))) {
    42             dsCity = OsmReader.parseDataSet(in, NullProgressMonitor.INSTANCE);
    43         }
     36        dsCity = PerformanceTestUtils.getNeubrandenburgDataSet();
    4437    }
    4538
  • trunk/test/performance/org/openstreetmap/josm/gui/mappaint/MapRendererPerformanceTest.java

    r17275 r17615  
    1010import java.io.File;
    1111import java.io.IOException;
    12 import java.io.InputStream;
    1312import java.util.ArrayList;
    1413import java.util.Collections;
     
    4443import org.openstreetmap.josm.gui.mappaint.mapcss.Selector;
    4544import org.openstreetmap.josm.gui.mappaint.styleelement.StyleElement;
    46 import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    47 import org.openstreetmap.josm.io.Compression;
    48 import org.openstreetmap.josm.io.OsmReader;
    4945import org.openstreetmap.josm.testutils.JOSMTestRules;
    5046
     
    169165        MapPaintStyleLoader.reloadStyles(defaultStyleIdx);
    170166
    171         try (
    172             InputStream fisC = Compression.getUncompressedFileInputStream(new File("nodist/data/neubrandenburg.osm.bz2"));
    173         ) {
    174             dsCity = OsmReader.parseDataSet(fisC, NullProgressMonitor.INSTANCE);
    175         }
     167        dsCity = PerformanceTestUtils.getNeubrandenburgDataSet();
    176168    }
    177169
  • trunk/test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSPerformanceTest.java

    r17275 r17615  
    1313import org.junit.jupiter.api.BeforeAll;
    1414import org.openstreetmap.josm.JOSMFixture;
     15import org.openstreetmap.josm.PerformanceTestUtils;
    1516import org.openstreetmap.josm.data.Bounds;
    1617import org.openstreetmap.josm.data.osm.DataSet;
     
    2021import org.openstreetmap.josm.gui.NavigatableComponent;
    2122import org.openstreetmap.josm.gui.mappaint.MapRendererPerformanceTest;
    22 import org.openstreetmap.josm.io.Compression;
    2323import org.openstreetmap.josm.io.IllegalDataException;
    24 import org.openstreetmap.josm.io.OsmReader;
    2524
    2625/**
     
    3736    static final String STYLE_FILE = "resources/styles/standard/elemstyles.mapcss";
    3837
    39     /**
    40      * The data file to be rendered
    41      */
    42     static final String DATA_FILE = "nodist/data/neubrandenburg.osm.bz2";
    4338    /* ------------------------ / configuration section  ---------------------------- */
    4439
     
    8984
    9085    void loadData() throws IllegalDataException, IOException {
    91         System.out.print("Loading data file '"+DATA_FILE+"' ...");
    92         ds = OsmReader.parseDataSet(Compression.getUncompressedFileInputStream(new File(DATA_FILE)), null);
     86        System.out.print("Loading data file '"+PerformanceTestUtils.DATA_FILE+"' ...");
     87        ds = PerformanceTestUtils.getNeubrandenburgDataSet();
    9388        System.out.println("DONE");
    9489    }
     
    116111        );
    117112        System.out.println("DONE");
    118         System.out.println("data file : "+DATA_FILE);
     113        System.out.println("data file : "+PerformanceTestUtils.DATA_FILE);
    119114        System.out.println("style file: "+STYLE_FILE);
    120115        System.out.println("");
  • trunk/test/performance/org/openstreetmap/josm/io/OsmReaderPerformanceTest.java

    r17275 r17615  
    3030class OsmReaderPerformanceTest {
    3131    private static final int TIMES = 4;
    32     private static final String DATA_FILE = "nodist/data/neubrandenburg.osm.bz2";
    3332
    3433    /**
     
    6564            is.reset();
    6665
    67             ds = OsmReader.parseDataSet(decompressBeforeRead ? is : Compression.byExtension(DATA_FILE)
     66            ds = OsmReader.parseDataSet(decompressBeforeRead ? is : Compression.byExtension(PerformanceTestUtils.DATA_FILE)
    6867                    .getUncompressedInputStream(is), null);
    6968        }
     
    7372
    7473    private InputStream loadFile(boolean decompressBeforeRead) throws IOException {
    75         File file = new File(DATA_FILE);
     74        File file = new File(PerformanceTestUtils.DATA_FILE);
    7675        try (InputStream is = decompressBeforeRead ? Compression.getUncompressedFileInputStream(file) : new FileInputStream(file)) {
    7776            ByteArrayOutputStream temporary = new ByteArrayOutputStream();
Note: See TracChangeset for help on using the changeset viewer.