Index: trunk/test/performance/org/openstreetmap/josm/gui/mappaint/MapRendererPerformanceTest.java
===================================================================
--- trunk/test/performance/org/openstreetmap/josm/gui/mappaint/MapRendererPerformanceTest.java	(revision 16533)
+++ trunk/test/performance/org/openstreetmap/josm/gui/mappaint/MapRendererPerformanceTest.java	(revision 16542)
@@ -4,4 +4,5 @@
 import java.awt.Color;
 import java.awt.Graphics2D;
+import java.awt.Point;
 import java.awt.image.BufferedImage;
 import java.io.File;
@@ -10,6 +11,6 @@
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.EnumMap;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
@@ -35,5 +36,4 @@
 import org.openstreetmap.josm.data.preferences.sources.SourceEntry;
 import org.openstreetmap.josm.data.projection.ProjectionRegistry;
-import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.NavigatableComponent;
 import org.openstreetmap.josm.gui.mappaint.StyleSetting.BooleanStyleSetting;
@@ -46,7 +46,8 @@
 import org.openstreetmap.josm.io.OsmReader;
 import org.openstreetmap.josm.testutils.JOSMTestRules;
-import org.openstreetmap.josm.tools.Logging;
 
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
+import static org.junit.Assert.assertEquals;
 
 /**
@@ -100,9 +101,25 @@
         img = new BufferedImage(IMG_WIDTH, IMG_HEIGHT, BufferedImage.TYPE_INT_ARGB);
         g = (Graphics2D) img.getGraphics();
-        g.setClip(0, 0, IMG_WIDTH, IMG_WIDTH);
+        g.setClip(0, 0, IMG_WIDTH, IMG_HEIGHT);
         g.setColor(Color.BLACK);
-        g.fillRect(0, 0, IMG_WIDTH, IMG_WIDTH);
-        nc = MainApplication.getMap().mapView;
-        nc.setBounds(0, 0, IMG_WIDTH, IMG_HEIGHT);
+        g.fillRect(0, 0, IMG_WIDTH, IMG_HEIGHT);
+
+        nc = new NavigatableComponent() {
+            {
+                setBounds(0, 0, IMG_WIDTH, IMG_HEIGHT);
+                updateLocationState();
+            }
+
+            @Override
+            protected boolean isVisibleOnScreen() {
+                return true;
+            }
+
+            @Override
+            public Point getLocationOnScreen() {
+                return new Point(0, 0);
+            }
+        };
+        nc.zoomTo(BOUNDS_CITY_ALL);
 
         MapPaintStyles.readFromPreferences();
@@ -175,6 +192,6 @@
         public LatLon center = LL_CITY;
         public Bounds bounds;
-        public int noWarmup = 3;
-        public int noIterations = 7;
+        public int noWarmup = 20;
+        public int noIterations = 30;
         public boolean dumpImage = DUMP_IMAGE;
         public boolean clearStyleCache = true;
@@ -208,18 +225,13 @@
 
             StyledMapRenderer renderer = new StyledMapRenderer(g, nc, false);
+            assertEquals(IMG_WIDTH, (int) nc.getState().getViewWidth());
+            assertEquals(IMG_HEIGHT, (int) nc.getState().getViewHeight());
 
             int noTotal = noWarmup + noIterations;
             for (int i = 1; i <= noTotal; i++) {
                 g.setColor(Color.BLACK);
-                g.fillRect(0, 0, IMG_WIDTH, IMG_WIDTH);
+                g.fillRect(0, 0, IMG_WIDTH, IMG_HEIGHT);
                 if (clearStyleCache) {
                     MapPaintStyles.getStyles().clearCached();
-                }
-                System.gc();
-                System.runFinalization();
-                try {
-                    Thread.sleep(300);
-                } catch (InterruptedException ex) {
-                    Logging.warn(ex);
                 }
                 BenchmarkData data = new BenchmarkData();
@@ -234,7 +246,7 @@
                 }
                 if (i == 1) {
-                    dumpElementCount(data);
-                }
-                dumpTimes(data);
+                    data.dumpElementCount();
+                }
+                data.dumpTimes();
                 if (dumpImage && i == noTotal) {
                     dumpRenderedImage(label);
@@ -276,6 +288,4 @@
         test.label = "big";
         test.dumpImage = false;
-        test.noWarmup = 3;
-        test.noIterations = 10;
         test.mpGenerate = true;
         test.clearStyleCache = true;
@@ -285,6 +295,4 @@
     private static void testDrawFeature(Feature feature) throws IOException {
         PerformanceTester test = new PerformanceTester();
-        test.noWarmup = 3;
-        test.noIterations = 10;
         test.mpDraw = true;
         test.clearStyleCache = false;
@@ -302,4 +310,5 @@
         }
         MapPaintStyleLoader.reloadStyles(filterStyleIdx);
+        dsCity.clearMappaintCache();
         test.run();
     }
@@ -333,5 +342,5 @@
                 MapPaintStyles.toggleStyleActive(filterStyleIdx);
             }
-            Assert.assertEquals(active, filterStyle.active);
+            // Assert.assertEquals(active, filterStyle.active);
         }
     }
@@ -340,13 +349,4 @@
         File outputfile = new File("test-neubrandenburg-"+id+".png");
         ImageIO.write(img, "png", outputfile);
-    }
-
-    public static void dumpTimes(BenchmarkData bd) {
-        System.out.print(String.format("gen. %3d, sort %3d, draw %3d%n", bd.getGenerateTime(), bd.getSortTime(), bd.getDrawTime()));
-    }
-
-    public static void dumpElementCount(BenchmarkData bd) {
-        System.out.println(bd.recordElementStats().entrySet().stream()
-                .map(e -> e.getKey().getSimpleName().replace("Element", "") + ":" + e.getValue()).collect(Collectors.joining(" ")));
     }
 
@@ -361,15 +361,18 @@
         }
 
-        private Map<Class<? extends StyleElement>, Integer> recordElementStats() {
-            Map<Class<? extends StyleElement>, Integer> styleElementCount = new HashMap<>();
-            for (StyleRecord r : allStyleElems) {
-                Class<? extends StyleElement> klass = r.getStyle().getClass();
-                Integer count = styleElementCount.get(klass);
-                if (count == null) {
-                    count = 0;
-                }
-                styleElementCount.put(klass, count + 1);
-            }
-            return styleElementCount;
+        private Map<Class<? extends StyleElement>, Long> recordElementStats() {
+            return allStyleElems.stream()
+                    .collect(Collectors.groupingBy(r -> r.getStyle().getClass(), Collectors.counting()));
+        }
+
+        public void dumpTimes() {
+            System.out.print(String.format("gen. %4d, sort %4d, draw %4d%n", getGenerateTime(), getSortTime(), getDrawTime()));
+        }
+
+        public void dumpElementCount() {
+            System.out.println(recordElementStats().entrySet().stream()
+                    .sorted(Comparator.comparing(e -> e.getKey().getSimpleName()))
+                    .map(e -> e.getKey().getSimpleName().replace("Element", "") + ":" + e.getValue())
+                    .collect(Collectors.joining(" ")));
         }
     }
