Changeset 10697 in josm for trunk/test/performance/org/openstreetmap
- Timestamp:
- 2016-08-01T22:56:04+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/performance/org/openstreetmap/josm/gui/mappaint/MapRendererPerformanceTest.java
r10222 r10697 11 11 import java.util.Collections; 12 12 import java.util.EnumMap; 13 import java.util.HashMap; 13 14 import java.util.List; 14 15 import java.util.Locale; 15 16 import java.util.Map; 17 import java.util.stream.Collectors; 16 18 17 19 import javax.imageio.ImageIO; … … 30 32 import org.openstreetmap.josm.data.coor.LatLon; 31 33 import org.openstreetmap.josm.data.osm.DataSet; 34 import org.openstreetmap.josm.data.osm.visitor.paint.RenderBenchmarkCollector.CapturingBenchmark; 32 35 import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer; 36 import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer.StyleRecord; 33 37 import org.openstreetmap.josm.data.projection.Projections; 34 38 import org.openstreetmap.josm.gui.NavigatableComponent; … … 208 212 Main.warn(ex); 209 213 } 210 StyledMapRenderer.BenchmarkData data = new StyledMapRenderer.BenchmarkData(); 211 data.skipDraw = skipDraw; 212 renderer.benchmarkData = data; 214 BenchmarkData data = new BenchmarkData(); 215 renderer.setBenchmarkFactory(() -> data); 213 216 renderer.render(dsCity, false, bounds); 214 217 215 218 if (i > noWarmup) { 216 generateTimes.add(data.ge nerateTime);217 sortTimes.add(data. sortTime);218 drawTimes.add(data. drawTime);219 totalTimes.add(data.ge nerateTime + data.sortTime + data.drawTime);219 generateTimes.add(data.getGenerateTime()); 220 sortTimes.add(data.getSortTime()); 221 drawTimes.add(data.getDrawTime()); 222 totalTimes.add(data.getGenerateTime() + data.getSortTime() + data.getDrawTime()); 220 223 } 221 224 if (i == 1) { … … 318 321 } 319 322 320 public static void dumpTimes(StyledMapRenderer.BenchmarkData bd) { 321 System.out.print(String.format("gen. %3d, sort %3d, draw %3d%n", bd.generateTime, bd.sortTime, bd.drawTime)); 322 } 323 324 public static void dumpElementCount(StyledMapRenderer.BenchmarkData bd) { 325 String sep = null; 326 for (Map.Entry<Class<? extends StyleElement>, Integer> e : bd.styleElementCount.entrySet()) { 327 if (sep == null) { 328 sep = " "; 329 } else { 330 System.out.print(sep); 331 } 332 System.out.print(e.getKey().getSimpleName().replace("Element", "") + ":" + e.getValue()); 333 } 334 System.out.println(); 323 public static void dumpTimes(BenchmarkData bd) { 324 System.out.print(String.format("gen. %3d, sort %3d, draw %3d%n", bd.getGenerateTime(), bd.getSortTime(), bd.getDrawTime())); 325 } 326 327 public static void dumpElementCount(BenchmarkData bd) { 328 System.out.println(bd.recordElementStats().entrySet().stream() 329 .map(e -> e.getKey().getSimpleName().replace("Element", "") + ":" + e.getValue()).collect(Collectors.joining(" "))); 330 } 331 332 public static class BenchmarkData extends CapturingBenchmark { 333 334 private List<StyleRecord> allStyleElems; 335 336 @Override 337 public boolean renderDraw(List<StyleRecord> allStyleElems) { 338 this.allStyleElems = allStyleElems; 339 return super.renderDraw(allStyleElems); 340 } 341 342 private Map<Class<? extends StyleElement>, Integer> recordElementStats() { 343 Map<Class<? extends StyleElement>, Integer> styleElementCount = new HashMap<>(); 344 for (StyleRecord r : allStyleElems) { 345 Class<? extends StyleElement> klass = r.getStyle().getClass(); 346 Integer count = styleElementCount.get(klass); 347 if (count == null) { 348 count = 0; 349 } 350 styleElementCount.put(klass, count + 1); 351 } 352 return styleElementCount; 353 } 335 354 } 336 355 }
Note:
See TracChangeset
for help on using the changeset viewer.