Changeset 9786 in josm for trunk/src/org
- Timestamp:
- 2016-02-11T23:37:07+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
r9351 r9786 33 33 import java.util.List; 34 34 import java.util.Map; 35 import java.util.Map.Entry; 35 36 import java.util.concurrent.ForkJoinPool; 36 37 import java.util.concurrent.ForkJoinTask; … … 237 238 } 238 239 240 /** 241 * Saves benchmark data for tests. 242 */ 243 public static class BenchmarkData { 244 public long generateTime; 245 public long sortTime; 246 public long drawTime; 247 public Map<Class<? extends StyleElement>, Integer> styleElementCount; 248 public boolean skipDraw; 249 250 private void recordElementStats(List<StyleRecord> srs) { 251 styleElementCount = new HashMap<>(); 252 for (StyleRecord r : srs) { 253 Class<? extends StyleElement> klass = r.style.getClass(); 254 Integer count = styleElementCount.get(klass); 255 if (count == null) { 256 count = 0; 257 } 258 styleElementCount.put(klass, count + 1); 259 } 260 261 } 262 } 263 /* can be set by tests, if detailed benchmark data is requested */ 264 public BenchmarkData benchmarkData = null; 265 239 266 private static Map<Font, Boolean> IS_GLYPH_VECTOR_DOUBLE_TRANSLATION_BUG = new HashMap<>(); 240 267 … … 1868 1895 BBox bbox = bounds.toBBox(); 1869 1896 getSettings(renderVirtualNodes); 1870 boolean benchmark = Main.isTraceEnabled() || Main.pref.getBoolean("mappaint.render.benchmark", false); 1897 boolean benchmarkOutput = Main.isTraceEnabled() || Main.pref.getBoolean("mappaint.render.benchmark", false); 1898 boolean benchmark = benchmarkOutput || benchmarkData != null; 1871 1899 1872 1900 data.getReadLock().lock(); … … 1874 1902 highlightWaySegments = data.getHighlightedWaySegments(); 1875 1903 1876 long timeStart = 0, time Phase1= 0, timeFinished;1904 long timeStart = 0, timeGenerateDone = 0, timeSortingDone = 0, timeFinished; 1877 1905 if (benchmark) { 1878 1906 timeStart = System.currentTimeMillis(); … … 1897 1925 1898 1926 if (benchmark) { 1899 timePhase1 = System.currentTimeMillis(); 1900 System.err.print("phase 1 (calculate styles): " + Utils.getDurationString(timePhase1 - timeStart)); 1927 timeGenerateDone = System.currentTimeMillis(); 1928 if (benchmarkOutput) { 1929 System.err.print("phase 1 (calculate styles): " + Utils.getDurationString(timeGenerateDone - timeStart)); 1930 } 1931 if (benchmarkData != null) { 1932 benchmarkData.generateTime = timeGenerateDone - timeStart; 1933 } 1901 1934 } 1902 1935 1903 1936 Collections.sort(allStyleElems); // TODO: try parallel sort when switching to Java 8 1937 1938 if (benchmarkData != null) { 1939 timeSortingDone = System.currentTimeMillis(); 1940 benchmarkData.sortTime = timeSortingDone - timeGenerateDone; 1941 if (benchmarkData.skipDraw) { 1942 benchmarkData.recordElementStats(allStyleElems); 1943 return; 1944 } 1945 } 1904 1946 1905 1947 for (StyleRecord r : allStyleElems) { … … 1916 1958 if (benchmark) { 1917 1959 timeFinished = System.currentTimeMillis(); 1918 System.err.println("; phase 2 (draw): " + Utils.getDurationString(timeFinished - timePhase1) + 1919 "; total: " + Utils.getDurationString(timeFinished - timeStart) + 1920 " (scale: " + circum + " zoom level: " + Selector.GeneralSelector.scale2level(circum) + ')'); 1960 if (benchmarkData != null) { 1961 benchmarkData.drawTime = timeFinished - timeGenerateDone; 1962 benchmarkData.recordElementStats(allStyleElems); 1963 } 1964 if (benchmarkOutput) { 1965 System.err.println("; phase 2 (draw): " + Utils.getDurationString(timeFinished - timeGenerateDone) + 1966 "; total: " + Utils.getDurationString(timeFinished - timeStart) + 1967 " (scale: " + circum + " zoom level: " + Selector.GeneralSelector.scale2level(circum) + ')'); 1968 } 1921 1969 } 1922 1970 -
trunk/src/org/openstreetmap/josm/gui/mappaint/StyleSetting.java
r8674 r9786 60 60 @Override 61 61 public void actionPerformed(ActionEvent e) { 62 boolean b = item.isSelected(); 63 if (b == def) { 64 Main.pref.put(prefKey, null); 65 } else { 66 Main.pref.put(prefKey, b); 67 } 62 setValue(item.isSelected()); 68 63 Main.worker.submit(new MapPaintStyles.MapPaintStyleLoader(Arrays.asList(parentStyle))); 69 64 } … … 95 90 return Boolean.valueOf(val); 96 91 } 92 93 public void setValue(Object o) { 94 if (o == null || !(o instanceof Boolean)) { 95 throw new IllegalArgumentException(); 96 } 97 boolean b = (Boolean) o; 98 if (b == def) { 99 Main.pref.put(prefKey, null); 100 } else { 101 Main.pref.put(prefKey, b); 102 } 103 } 97 104 } 98 105 }
Note:
See TracChangeset
for help on using the changeset viewer.