Changeset 7068 in josm for trunk/test/performance/org/openstreetmap
- Timestamp:
- 2014-05-06T01:24:41+02:00 (11 years ago)
- 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. 1 2 package org.openstreetmap.josm.data.osm; 3 4 import static org.junit.Assert.assertTrue; 2 5 3 6 import org.junit.Test; … … 5 8 import org.openstreetmap.josm.data.coor.LatLonTest; 6 9 7 import static org.junit.Assert.assertTrue; 10 public class RoundingPerformanceTest { 8 11 9 public class RoundingPerformanceTest extends LatLonTest {10 11 12 private static double oldRoundToOsmPrecision(double value) { 12 13 return Math.round(value / LatLon.MAX_SERVER_PRECISION) * LatLon.MAX_SERVER_PRECISION; // Old method, causes rounding errors, but efficient … … 18 19 long start = System.nanoTime(); 19 20 for (int i = 0; i < n; i++) { 20 for (double value : sampleValues) {21 for (double value : LatLonTest.SAMPLE_VALUES) { 21 22 oldRoundToOsmPrecision(value); 22 23 } … … 25 26 long oldTime = end-start; 26 27 System.out.println("Old time: "+oldTime/1000000.0 + " ms"); 27 28 28 29 start = System.nanoTime(); 29 30 for (int i = 0; i < n; i++) { 30 for (double value : sampleValues) {31 for (double value : LatLonTest.SAMPLE_VALUES) { 31 32 LatLon.roundToOsmPrecision(value); 32 33 } … … 35 36 long newTime = end-start; 36 37 System.out.println("New time: "+newTime/1000000.0 + " ms"); 37 38 38 39 assertTrue(newTime <= oldTime*10); 39 40 } -
trunk/test/performance/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRendererPerformanceTest.java
r7065 r7068 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.data.osm ;2 package org.openstreetmap.josm.data.osm.visitor.paint; 3 3 4 4 import java.awt.Graphics2D; … … 11 11 import org.openstreetmap.josm.Main; 12 12 import org.openstreetmap.josm.data.Bounds; 13 import org.openstreetmap.josm.data.osm.DataSet; 13 14 import org.openstreetmap.josm.data.osm.visitor.paint.Rendering; 14 15 import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer; … … 19 20 import org.openstreetmap.josm.io.OsmReader; 20 21 21 public class MapPaintVisitorPerformanceTest {22 public class StyledMapRendererPerformanceTest { 22 23 23 24 private static final int IMG_WIDTH = 1400; … … 54 55 55 56 // Warm up 56 new MapPaintVisitorPerformanceTest().testRestrictionSmall();57 new MapPaintVisitorPerformanceTest().testCity();57 new StyledMapRendererPerformanceTest().testRestrictionSmall(); 58 new StyledMapRendererPerformanceTest().testCity(); 58 59 } 59 60 -
trunk/test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSPerformanceTest.groovy
r7065 r7068 1 2 1 // License: GPL. For details, see LICENSE file. 3 package mapcss.performance;2 package org.openstreetmap.josm.gui.mappaint.mapcss; 4 3 5 4 import static org.junit.Assert.* … … 16 15 import org.openstreetmap.josm.gui.layer.OsmDataLayer 17 16 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles 18 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource19 17 import org.openstreetmap.josm.gui.preferences.SourceEntry 20 18 import org.openstreetmap.josm.io.OsmReader 21 19 22 20 /** 23 * This performance test smeasures the time for a full run of MapPaintVisitor.visitAll()21 * This performance test measures the time for a full run of MapPaintVisitor.visitAll() 24 22 * against a test data set using a test style. 25 * 23 * 26 24 */ 27 class PerformanceTest {25 class MapCSSPerformanceTest { 28 26 29 27 /* ------------------------ configuration section ---------------------------- */ 30 28 /** 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" 39 32 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 46 44 def DataSet ds 47 45 48 46 def static boolean checkTestEnvironment() { 49 47 File f = new File(JOSM_HOME) 50 48 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.") 52 50 } 53 51 54 52 f = new File(STYLE_FILE); 55 53 if ( !f.isFile() || ! f.exists()) { 56 54 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.") 57 55 } 58 56 59 57 f = new File(DATA_FILE); 60 58 if ( !f.isFile() || ! f.exists()) { … … 62 60 } 63 61 } 64 62 65 63 @BeforeClass 66 64 public static void createJOSMFixture(){ … … 69 67 MainApplication.main(new String[0]) 70 68 } 71 69 72 70 def timed(Closure c){ 73 71 long before = System.currentTimeMillis() … … 76 74 return after - before 77 75 } 78 76 79 77 def loadStyle() { 80 78 print "Loading style '$STYLE_FILE' ..." … … 95 93 println "DONE" 96 94 } 97 95 98 96 def loadData() { 99 97 print "Loading data file '$DATA_FILE' ..." … … 105 103 println "DONE" 106 104 } 107 105 108 106 @Test 109 107 public void measureTimeForStylePreparation() { 110 108 loadStyle() 111 109 loadData() 112 110 113 111 def mv = Main.map.mapView 114 112 115 113 BufferedImage img = mv.createImage(mv.getWidth(), mv.getHeight()) 116 114 Graphics2D g = img.createGraphics() 117 115 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) 121 117 122 118 print "Rendering ..." … … 128 124 println "style file: ${STYLE_FILE}" 129 125 println "" 130 println "Rendering took $time ms." 126 println "Rendering took $time ms." 131 127 } 132 128 }
Note:
See TracChangeset
for help on using the changeset viewer.