Changeset 17618 in josm for trunk/test/performance/org/openstreetmap
- Timestamp:
- 2021-03-21T13:56:19+01:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/performance/org/openstreetmap/josm/PerformanceTestUtils.java
r17617 r17618 16 16 17 17 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 18 import org.openstreetmap.josm.tools.Stopwatch; 18 19 19 20 /** … … 44 45 45 46 /** 46 * A helper class that captures the time from object creation until #done() was called.47 * @author Michael Zangl48 */49 public static class PerformanceTestTimerCapture {50 private final long time;51 52 protected PerformanceTestTimerCapture() {53 time = System.nanoTime();54 }55 56 /**57 * Get the time since this object was created.58 * @return The time.59 */60 public long getTimeSinceCreation() {61 return (System.nanoTime() - time) / 1000000;62 }63 }64 65 /**66 47 * A timer that measures the time from it's creation to the {@link #done()} call. 67 48 * @author Michael Zangl 68 49 */ 69 public static class PerformanceTestTimer extends PerformanceTestTimerCapture { 50 public static class PerformanceTestTimer { 51 private final Stopwatch stopwatch = Stopwatch.createStarted(); 70 52 private final String name; 71 53 private boolean measurementPlotsPlugin = true; … … 87 69 */ 88 70 public void done() { 89 long dTime = getTimeSinceCreation();71 long dTime = stopwatch.elapsed(); 90 72 if (measurementPlotsPlugin) { 91 73 measurementPlotsPluginOutput(name + "(ms)", dTime); … … 120 102 for (int i = 0; i < TIMES_WARMUP; i++) { 121 103 cleanSystem(); 122 PerformanceTestTimerCapture capture = new PerformanceTestTimerCapture();104 Stopwatch capture = Stopwatch.createStarted(); 123 105 testRunner.run(); 124 capture. getTimeSinceCreation();106 capture.elapsed(); 125 107 } 126 108 ArrayList<Long> times = new ArrayList<>(); 127 109 for (int i = 0; i < TIMES_RUN; i++) { 128 110 cleanSystem(); 129 PerformanceTestTimerCapture capture = new PerformanceTestTimerCapture();111 Stopwatch stopwatch = Stopwatch.createStarted(); 130 112 testRunner.run(); 131 times.add( capture.getTimeSinceCreation());113 times.add(stopwatch.elapsed()); 132 114 } 133 115 System.out.println(times);
Note:
See TracChangeset
for help on using the changeset viewer.