Ignore:
Timestamp:
2014-05-06T01:24:41+02:00 (10 years ago)
Author:
Don-vip
Message:

test cleanup

Location:
trunk/test/performance/org/openstreetmap/josm
Files:
5 added
1 edited
1 copied
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/test/performance/org/openstreetmap/josm/data/osm/RoundingPerformanceTest.java

    r4573 r7068  
     1// License: GPL. For details, see LICENSE file.
    12package org.openstreetmap.josm.data.osm;
     3
     4import static org.junit.Assert.assertTrue;
    25
    36import org.junit.Test;
     
    58import org.openstreetmap.josm.data.coor.LatLonTest;
    69
    7 import static org.junit.Assert.assertTrue;
     10public class RoundingPerformanceTest {
    811
    9 public class RoundingPerformanceTest extends LatLonTest {
    10    
    1112    private static double oldRoundToOsmPrecision(double value) {
    1213        return Math.round(value / LatLon.MAX_SERVER_PRECISION) * LatLon.MAX_SERVER_PRECISION; // Old method, causes rounding errors, but efficient
     
    1819        long start = System.nanoTime();
    1920        for (int i = 0; i < n; i++) {
    20             for (double value : sampleValues) {
     21            for (double value : LatLonTest.SAMPLE_VALUES) {
    2122                oldRoundToOsmPrecision(value);
    2223            }
     
    2526        long oldTime = end-start;
    2627        System.out.println("Old time: "+oldTime/1000000.0 + " ms");
    27        
     28
    2829        start = System.nanoTime();
    2930        for (int i = 0; i < n; i++) {
    30             for (double value : sampleValues) {
     31            for (double value : LatLonTest.SAMPLE_VALUES) {
    3132                LatLon.roundToOsmPrecision(value);
    3233            }
     
    3536        long newTime = end-start;
    3637        System.out.println("New time: "+newTime/1000000.0 + " ms");
    37        
     38
    3839        assertTrue(newTime <= oldTime*10);
    3940    }
  • trunk/test/performance/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRendererPerformanceTest.java

    r7065 r7068  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.data.osm;
     2package org.openstreetmap.josm.data.osm.visitor.paint;
    33
    44import java.awt.Graphics2D;
     
    1111import org.openstreetmap.josm.Main;
    1212import org.openstreetmap.josm.data.Bounds;
     13import org.openstreetmap.josm.data.osm.DataSet;
    1314import org.openstreetmap.josm.data.osm.visitor.paint.Rendering;
    1415import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
     
    1920import org.openstreetmap.josm.io.OsmReader;
    2021
    21 public class MapPaintVisitorPerformanceTest {
     22public class StyledMapRendererPerformanceTest {
    2223
    2324    private static final int IMG_WIDTH = 1400;
     
    5455
    5556        // Warm up
    56         new MapPaintVisitorPerformanceTest().testRestrictionSmall();
    57         new MapPaintVisitorPerformanceTest().testCity();
     57        new StyledMapRendererPerformanceTest().testRestrictionSmall();
     58        new StyledMapRendererPerformanceTest().testCity();
    5859    }
    5960
  • trunk/test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSPerformanceTest.groovy

    r7065 r7068  
    1 
    21// License: GPL. For details, see LICENSE file.
    3 package mapcss.performance;
     2package org.openstreetmap.josm.gui.mappaint.mapcss;
    43
    54import static org.junit.Assert.*
     
    1615import org.openstreetmap.josm.gui.layer.OsmDataLayer
    1716import org.openstreetmap.josm.gui.mappaint.MapPaintStyles
    18 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource
    1917import org.openstreetmap.josm.gui.preferences.SourceEntry
    2018import org.openstreetmap.josm.io.OsmReader
    2119
    2220/**
    23  * This performance tests measures the time for a full run of MapPaintVisitor.visitAll()
     21 * This performance test measures the time for a full run of MapPaintVisitor.visitAll()
    2422 * against a test data set using a test style.
    25  * 
     23 *
    2624 */
    27 class PerformanceTest {
     25class MapCSSPerformanceTest {
    2826
    2927    /* ------------------------ configuration section  ---------------------------- */
    3028    /**
    31     * The path to the JOSM home environment
    32     */
    33    def static JOSM_HOME="/my/josm/home/dir"
    34    
    35    /**
    36     * The path to the style file used for rendering.
    37     */
    38    def static STYLE_FILE="/my/test-style.mapcss"
     29     * The path to the JOSM home environment
     30     */
     31    def static JOSM_HOME="test/config/performance-josm.home"
    3932
    40    /**
    41     * The data file to be rendered
    42     */
    43    def static DATA_FILE = "/my/test-data.osm"
    44     /* ------------------------ / configuration section  ---------------------------- */     
    45    
     33    /**
     34     * The path to the style file used for rendering.
     35     */
     36    def static STYLE_FILE="styles/standard/elemstyles.mapcss"
     37
     38    /**
     39     * The data file to be rendered
     40     */
     41    def static DATA_FILE = "/my/test-data.osm"
     42    /* ------------------------ / configuration section  ---------------------------- */
     43
    4644    def DataSet ds
    47    
     45
    4846    def static boolean checkTestEnvironment() {
    4947          File f = new File(JOSM_HOME)
    5048          if  (!f.isDirectory() || !f.exists()) {
    51               fail("JOSM_HOME refers to '${JOSM_HOME}. This is either not a directory or doesn't exist.\nPlease update configuration settings in the unit test file.")             
     49              fail("JOSM_HOME refers to '${JOSM_HOME}. This is either not a directory or doesn't exist.\nPlease update configuration settings in the unit test file.")
    5250          }
    53          
     51
    5452          f = new File(STYLE_FILE);
    5553          if ( !f.isFile() || ! f.exists()) {
    5654              fail("STYLE_FILE refers to '${STYLE_FILE}. This is either not a file or doesn't exist.\nPlease update configuration settings in the unit test file.")
    5755          }
    58          
     56
    5957          f = new File(DATA_FILE);
    6058          if ( !f.isFile() || ! f.exists()) {
     
    6260          }
    6361    }
    64    
     62
    6563    @BeforeClass
    6664    public static void createJOSMFixture(){
     
    6967        MainApplication.main(new String[0])
    7068    }
    71    
     69
    7270    def timed(Closure c){
    7371        long before = System.currentTimeMillis()
     
    7674        return after - before
    7775    }
    78    
     76
    7977    def  loadStyle() {
    8078        print "Loading style '$STYLE_FILE' ..."
     
    9593        println "DONE"
    9694    }
    97    
     95
    9896    def loadData() {
    9997        print "Loading data file '$DATA_FILE' ..."
     
    105103        println "DONE"
    106104    }
    107    
     105
    108106    @Test
    109107    public void measureTimeForStylePreparation() {
    110108        loadStyle()
    111109        loadData()
    112        
     110
    113111        def mv = Main.map.mapView
    114        
     112
    115113        BufferedImage img = mv.createImage(mv.getWidth(), mv.getHeight())
    116114        Graphics2D g = img.createGraphics()
    117115        g.setClip(0,0, mv.getWidth(), mv.getHeight())
    118         def visitor = new StyledMapRenderer()
    119         visitor.setNavigatableComponent(Main.map.mapView)
    120         visitor.setGraphics(g)
     116        def visitor = new StyledMapRenderer(g, Main.map.mapView, false)
    121117
    122118        print "Rendering ..."
     
    128124        println "style file: ${STYLE_FILE}"
    129125        println ""
    130         println "Rendering took $time ms."       
     126        println "Rendering took $time ms."
    131127    }
    132128}
Note: See TracChangeset for help on using the changeset viewer.