Changeset 15755 in josm for trunk/src/org
- Timestamp:
- 2020-01-23T22:57:46+01:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/MergeLayerAction.java
r15450 r15755 24 24 import org.openstreetmap.josm.tools.Logging; 25 25 import org.openstreetmap.josm.tools.Shortcut; 26 import org.openstreetmap.josm.tools.Stopwatch; 26 27 import org.openstreetmap.josm.tools.Utils; 27 28 … … 81 82 82 83 return MainApplication.worker.submit(() -> { 83 final long start = System.currentTimeMillis();84 final Stopwatch stopwatch = Stopwatch.createStarted(); 84 85 85 86 for (int i = sortedLayers.size() - 2; i >= 0; i--) { … … 89 90 } 90 91 91 Logging.info(tr("{0} completed in {1}", actionName, Utils.getDurationString(System.currentTimeMillis() - start)));92 Logging.info(tr("{0} completed in {1}", actionName, stopwatch)); 92 93 }); 93 94 } … … 95 96 96 97 return MainApplication.worker.submit(() -> { 97 final long start = System.currentTimeMillis();98 final Stopwatch stopwatch = Stopwatch.createStarted(); 98 99 boolean layerMerged = false; 99 100 for (final Layer sourceLayer: sourceLayers) { … … 113 114 if (layerMerged) { 114 115 getLayerManager().setActiveLayer(targetLayer); 115 Logging.info(tr("{0} completed in {1}", actionName, Utils.getDurationString(System.currentTimeMillis() - start)));116 Logging.info(tr("{0} completed in {1}", actionName, stopwatch)); 116 117 } 117 118 }); -
trunk/src/org/openstreetmap/josm/data/osm/DatasetConsistencyTest.java
r12620 r15755 10 10 import org.openstreetmap.josm.tools.JosmRuntimeException; 11 11 import org.openstreetmap.josm.tools.Logging; 12 import org.openstreetmap.josm.tools. Utils;12 import org.openstreetmap.josm.tools.Stopwatch; 13 13 14 14 /** … … 46 46 */ 47 47 public void checkReferrers() { 48 long startTime = System.currentTimeMillis();48 final Stopwatch stopwatch = Stopwatch.createStarted(); 49 49 // It's also error when referred primitive's dataset is null but it's already covered by referredPrimitiveNotInDataset check 50 50 for (Way way : dataSet.getWays()) { … … 67 67 } 68 68 } 69 printElapsedTime(st artTime);69 printElapsedTime(stopwatch); 70 70 } 71 71 … … 74 74 */ 75 75 public void checkCompleteWaysWithIncompleteNodes() { 76 long startTime = System.currentTimeMillis();76 final Stopwatch stopwatch = Stopwatch.createStarted(); 77 77 for (Way way : dataSet.getWays()) { 78 78 if (way.isUsable()) { … … 84 84 } 85 85 } 86 printElapsedTime(st artTime);86 printElapsedTime(stopwatch); 87 87 } 88 88 … … 91 91 */ 92 92 public void checkCompleteNodesWithoutCoordinates() { 93 long startTime = System.currentTimeMillis();93 final Stopwatch stopwatch = Stopwatch.createStarted(); 94 94 for (Node node : dataSet.getNodes()) { 95 95 if (!node.isIncomplete() && node.isVisible() && !node.isLatLonKnown()) { … … 97 97 } 98 98 } 99 printElapsedTime(st artTime);99 printElapsedTime(stopwatch); 100 100 } 101 101 … … 104 104 */ 105 105 public void searchNodes() { 106 long startTime = System.currentTimeMillis();106 final Stopwatch stopwatch = Stopwatch.createStarted(); 107 107 dataSet.getReadLock().lock(); 108 108 try { … … 116 116 dataSet.getReadLock().unlock(); 117 117 } 118 printElapsedTime(st artTime);118 printElapsedTime(stopwatch); 119 119 } 120 120 … … 123 123 */ 124 124 public void searchWays() { 125 long startTime = System.currentTimeMillis();125 final Stopwatch stopwatch = Stopwatch.createStarted(); 126 126 dataSet.getReadLock().lock(); 127 127 try { … … 134 134 dataSet.getReadLock().unlock(); 135 135 } 136 printElapsedTime(st artTime);136 printElapsedTime(stopwatch); 137 137 } 138 138 … … 155 155 */ 156 156 public void referredPrimitiveNotInDataset() { 157 long startTime = System.currentTimeMillis();157 final Stopwatch stopwatch = Stopwatch.createStarted(); 158 158 for (Way way : dataSet.getWays()) { 159 159 for (Node node : way.getNodes()) { … … 167 167 } 168 168 } 169 printElapsedTime(st artTime);169 printElapsedTime(stopwatch); 170 170 } 171 171 … … 174 174 */ 175 175 public void checkZeroNodesWays() { 176 long startTime = System.currentTimeMillis();176 final Stopwatch stopwatch = Stopwatch.createStarted(); 177 177 for (Way way : dataSet.getWays()) { 178 178 if (way.isUsable() && way.getNodesCount() == 0) { … … 182 182 } 183 183 } 184 printElapsedTime(st artTime);185 } 186 187 private void printElapsedTime( long startTime) {184 printElapsedTime(stopwatch); 185 } 186 187 private void printElapsedTime(Stopwatch stopwatch) { 188 188 if (Logging.isDebugEnabled()) { 189 189 StackTraceElement item = Thread.currentThread().getStackTrace()[2]; 190 190 String operation = getClass().getSimpleName() + '.' + item.getMethodName(); 191 long elapsedTime = System.currentTimeMillis() - startTime;192 191 Logging.debug(tr("Test ''{0}'' completed in {1}", 193 operation, Utils.getDurationString(elapsedTime)));192 operation, stopwatch)); 194 193 } 195 194 } … … 200 199 public void runTest() { 201 200 try { 202 long startTime = System.currentTimeMillis();201 final Stopwatch stopwatch = Stopwatch.createStarted(); 203 202 referredPrimitiveNotInDataset(); 204 203 checkReferrers(); … … 208 207 searchWays(); 209 208 checkZeroNodesWays(); 210 printElapsedTime(st artTime);209 printElapsedTime(stopwatch); 211 210 if (errorCount > MAX_ERRORS) { 212 211 writer.println((errorCount - MAX_ERRORS) + " more..."); -
trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java
r15704 r15755 79 79 import org.openstreetmap.josm.tools.AlphanumComparator; 80 80 import org.openstreetmap.josm.tools.Logging; 81 import org.openstreetmap.josm.tools. Utils;81 import org.openstreetmap.josm.tools.Stopwatch; 82 82 83 83 /** … … 609 609 if (!testsInitialized) { 610 610 Logging.debug("Initializing validator tests"); 611 final long startTime = System.currentTimeMillis();611 final Stopwatch stopwatch = Stopwatch.createStarted(); 612 612 initializeTests(getTests()); 613 613 testsInitialized = true; 614 if (Logging.isDebugEnabled()) { 615 final long elapsedTime = System.currentTimeMillis() - startTime; 616 Logging.debug("Initializing validator tests completed in {0}", Utils.getDurationString(elapsedTime)); 617 } 614 Logging.debug("Initializing validator tests completed in {0}", stopwatch); 618 615 } 619 616 } -
trunk/src/org/openstreetmap/josm/data/validation/Test.java
r15683 r15755 28 28 import org.openstreetmap.josm.tools.GBC; 29 29 import org.openstreetmap.josm.tools.Logging; 30 import org.openstreetmap.josm.tools. Utils;30 import org.openstreetmap.josm.tools.Stopwatch; 31 31 32 32 /** … … 75 75 76 76 /** the start time to compute elapsed time when test finishes */ 77 protected long startTime;77 protected Stopwatch stopwatch; 78 78 79 79 private boolean showElementCount; … … 154 154 */ 155 155 public void initialize() throws Exception { 156 this.st artTime = -1;156 this.stopwatch = Stopwatch.createStarted(); 157 157 } 158 158 … … 168 168 Logging.debug(startMessage); 169 169 this.errors = new ArrayList<>(30); 170 this.st artTime = System.currentTimeMillis();170 this.stopwatch = Stopwatch.createStarted(); 171 171 } 172 172 … … 197 197 progressMonitor.finishTask(); 198 198 progressMonitor = null; 199 if (startTime > 0) { 200 // fix #11567 where elapsedTime is < 0 201 long elapsedTime = Math.max(0, System.currentTimeMillis() - startTime); 202 Logging.debug(tr("Test ''{0}'' completed in {1}", getName(), Utils.getDurationString(elapsedTime))); 199 if (stopwatch.elapsed() > 0) { 200 Logging.debug(tr("Test ''{0}'' completed in {1}", getName(), stopwatch)); 203 201 } 204 202 } -
trunk/src/org/openstreetmap/josm/gui/SplashScreen.java
r15719 r15755 42 42 import org.openstreetmap.josm.tools.ImageProvider; 43 43 import org.openstreetmap.josm.tools.Logging; 44 import org.openstreetmap.josm.tools.Stopwatch; 44 45 import org.openstreetmap.josm.tools.Utils; 45 46 … … 150 151 private static class MeasurableTask extends Task { 151 152 private final String name; 152 private final long start;153 private final Stopwatch stopwatch; 153 154 private String duration = ""; 154 155 155 156 MeasurableTask(String name) { 156 157 this.name = name; 157 this.st art = System.currentTimeMillis();158 this.stopwatch = Stopwatch.createStarted(); 158 159 } 159 160 … … 162 163 throw new IllegalStateException("This task has already been finished: " + name); 163 164 } 164 long time = System.currentTimeMillis() - start; 165 if (time >= 0) { 166 duration = tr(" ({0})", Utils.getDurationString(time)); 165 if (stopwatch.elapsed() >= 0) { 166 duration = tr(" ({0})", stopwatch); 167 167 } 168 168 } -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java
r15606 r15755 58 58 import org.openstreetmap.josm.tools.JosmRuntimeException; 59 59 import org.openstreetmap.josm.tools.Logging; 60 import org.openstreetmap.josm.tools.Stopwatch; 60 61 import org.openstreetmap.josm.tools.Utils; 61 62 … … 420 421 public void drawAll(Graphics2D g, MapView mv, List<WayPoint> visibleSegments, Bounds clipBounds) { 421 422 422 final long timeStart = System.currentTimeMillis();423 final Stopwatch stopwatch = Stopwatch.createStarted(); 423 424 424 425 checkCache(); … … 487 488 // show some debug info 488 489 if (Logging.isDebugEnabled() && !visibleSegments.isEmpty()) { 489 final long timeDiff = System.currentTimeMillis() - timeStart;490 491 490 Logging.debug("gpxdraw::draw takes " + 492 Utils.getDurationString(timeDiff)+491 stopwatch + 493 492 "(" + 494 493 "segments= " + visibleSegments.size() + 495 ", per 10000 = " + Utils.getDurationString(10_000 * timeDiff/ visibleSegments.size()) +494 ", per 10000 = " + Utils.getDurationString(10_000 * stopwatch.elapsed() / visibleSegments.size()) + 496 495 ")" 497 496 ); -
trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java
r15717 r15755 29 29 import org.openstreetmap.josm.tools.ListenerList; 30 30 import org.openstreetmap.josm.tools.Logging; 31 import org.openstreetmap.josm.tools.Stopwatch; 31 32 import org.openstreetmap.josm.tools.Utils; 32 33 … … 321 322 322 323 private static void loadStyleForFirstTime(StyleSource source) { 323 final long startTime = System.currentTimeMillis();324 final Stopwatch stopwatch = Stopwatch.createStarted(); 324 325 source.loadStyleSource(); 325 326 if (Config.getPref().getBoolean("mappaint.auto_reload_local_styles", true) && source.isLocal()) { … … 331 332 } 332 333 if (Logging.isDebugEnabled() || !source.isValid()) { 333 final long elapsedTime = System.currentTimeMillis() - startTime; 334 String message = "Initializing map style " + source.url + " completed in " + Utils.getDurationString(elapsedTime); 334 String message = "Initializing map style " + source.url + " completed in " + stopwatch; 335 335 if (!source.isValid()) { 336 336 Logging.warn(message + " (" + source.getErrors().size() + " errors, " + source.getWarnings().size() + " warnings)"); -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetReader.java
r15072 r15755 47 47 import org.openstreetmap.josm.tools.I18n; 48 48 import org.openstreetmap.josm.tools.Logging; 49 import org.openstreetmap.josm.tools.Stopwatch; 49 50 import org.openstreetmap.josm.tools.Utils; 50 51 import org.openstreetmap.josm.tools.XmlObjectParser; … … 353 354 Collection<TaggingPreset> tp; 354 355 Logging.debug("Reading presets from {0}", source); 355 long startTime = System.currentTimeMillis();356 Stopwatch stopwatch = Stopwatch.createStarted(); 356 357 try ( 357 358 CachedFile cf = new CachedFile(source).setHttpAccept(PRESET_MIME_TYPES); … … 368 369 } 369 370 if (Logging.isDebugEnabled()) { 370 Logging.debug("Presets read in {0}", Utils.getDurationString(System.currentTimeMillis() - startTime));371 Logging.debug("Presets read in {0}", stopwatch); 371 372 } 372 373 return tp; -
trunk/src/org/openstreetmap/josm/tools/XmlUtils.java
r14441 r15755 84 84 */ 85 85 public static Document parseSafeDOM(InputStream is) throws ParserConfigurationException, IOException, SAXException { 86 long start = System.currentTimeMillis();86 Stopwatch stopwatch = Stopwatch.createStarted(); 87 87 Logging.debug("Starting DOM parsing of {0}", is); 88 88 Document result = newSafeDOMBuilder().parse(is); 89 if (Logging.isDebugEnabled()) { 90 Logging.debug("DOM parsing done in {0}", Utils.getDurationString(System.currentTimeMillis() - start)); 91 } 89 Logging.debug("DOM parsing done in {0}", stopwatch); 92 90 return result; 93 91 } … … 117 115 */ 118 116 public static void parseSafeSAX(InputSource is, DefaultHandler dh) throws ParserConfigurationException, SAXException, IOException { 119 long start = System.currentTimeMillis();117 Stopwatch stopwatch = Stopwatch.createStarted(); 120 118 Logging.debug("Starting SAX parsing of {0} using {1}", is, dh); 121 119 newSafeSAXParser().parse(is, dh); 122 if (Logging.isDebugEnabled()) { 123 Logging.debug("SAX parsing done in {0}", Utils.getDurationString(System.currentTimeMillis() - start)); 124 } 120 Logging.debug("SAX parsing done in {0}", stopwatch); 125 121 } 126 122
Note:
See TracChangeset
for help on using the changeset viewer.