Changeset 7068 in josm for trunk/test/performance/org/openstreetmap/josm/data/osm/RoundingPerformanceTest.java
- Timestamp:
- 2014-05-06T01:24:41+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/performance/org/openstreetmap/josm/data/osm/RoundingPerformanceTest.java
r4573 r7068 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.data.osm; 3 4 import static org.junit.Assert.assertTrue; 2 5 3 6 import org.junit.Test; … … 5 8 import org.openstreetmap.josm.data.coor.LatLonTest; 6 9 7 import static org.junit.Assert.assertTrue; 10 public class RoundingPerformanceTest { 8 11 9 public class RoundingPerformanceTest extends LatLonTest {10 11 12 private static double oldRoundToOsmPrecision(double value) { 12 13 return Math.round(value / LatLon.MAX_SERVER_PRECISION) * LatLon.MAX_SERVER_PRECISION; // Old method, causes rounding errors, but efficient … … 18 19 long start = System.nanoTime(); 19 20 for (int i = 0; i < n; i++) { 20 for (double value : sampleValues) {21 for (double value : LatLonTest.SAMPLE_VALUES) { 21 22 oldRoundToOsmPrecision(value); 22 23 } … … 25 26 long oldTime = end-start; 26 27 System.out.println("Old time: "+oldTime/1000000.0 + " ms"); 27 28 28 29 start = System.nanoTime(); 29 30 for (int i = 0; i < n; i++) { 30 for (double value : sampleValues) {31 for (double value : LatLonTest.SAMPLE_VALUES) { 31 32 LatLon.roundToOsmPrecision(value); 32 33 } … … 35 36 long newTime = end-start; 36 37 System.out.println("New time: "+newTime/1000000.0 + " ms"); 37 38 38 39 assertTrue(newTime <= oldTime*10); 39 40 }
Note:
See TracChangeset
for help on using the changeset viewer.