Changeset 7068 in josm for trunk/test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSPerformanceTest.groovy
- Timestamp:
- 2014-05-06T01:24:41+02:00 (10 years ago)
- Location:
- trunk/test/performance/org/openstreetmap/josm/gui
- Files:
-
- 3 added
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
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.