diff options
Diffstat (limited to 'tests/src/cgeo/geocaching/test')
6 files changed, 25 insertions, 27 deletions
diff --git a/tests/src/cgeo/geocaching/test/RegExPerformanceTest.java b/tests/src/cgeo/geocaching/test/RegExPerformanceTest.java index bd30532..ec84824 100644 --- a/tests/src/cgeo/geocaching/test/RegExPerformanceTest.java +++ b/tests/src/cgeo/geocaching/test/RegExPerformanceTest.java @@ -76,7 +76,7 @@ public class RegExPerformanceTest extends TestCase { } public static void testRegEx() { - List<String> output = doTheTests(10); + final List<String> output = doTheTests(10); for (String s : output) { System.out.println(s); @@ -85,7 +85,7 @@ public class RegExPerformanceTest extends TestCase { public static List<String> doTheTests(final int iterations) { - List<String> output = new ArrayList<String>(); + final List<String> output = new ArrayList<String>(); output.addAll(measure(iterations, "description", PATTERN_DESCRIPTION_OLD, PATTERN_DESCRIPTION)); @@ -94,7 +94,7 @@ public class RegExPerformanceTest extends TestCase { private static List<String> measure(int iterations, String fieldName, Pattern p1, Pattern p2) { - List<String> output = new ArrayList<String>(); + final List<String> output = new ArrayList<String>(); output.add(fieldName + ":"); for (MockedCache cache : MOCKED_CACHES) { @@ -106,15 +106,13 @@ public class RegExPerformanceTest extends TestCase { long diff1, diff2; output.add("Parsing " + cache.getGeocode() + " " + cache.getName()); - { - diff1 = parse(page, p1, iterations); - output.add("Time pattern 1:\t" + diff1 + " ms"); - } - - { - diff2 = parse(page, p2, iterations); - output.add("Time pattern 2:\t" + diff2 + " ms"); - } + + diff1 = parse(page, p1, iterations); + output.add("Time pattern 1:\t" + diff1 + " ms"); + + diff2 = parse(page, p2, iterations); + output.add("Time pattern 2:\t" + diff2 + " ms"); + float reduction = (float) diff2 * 100 / diff1; output.add("New runtime:\t" + String.format("%.1f", reduction) + "%\n"); } @@ -124,7 +122,7 @@ public class RegExPerformanceTest extends TestCase { } private static long parse(String page, Pattern pattern, int iterations) { - long start = System.currentTimeMillis(); + final long start = System.currentTimeMillis(); for (int j = 0; j < iterations; j++) { BaseUtils.getMatch(page, pattern, true, ""); } diff --git a/tests/src/cgeo/geocaching/test/RegExRealPerformanceTest.java b/tests/src/cgeo/geocaching/test/RegExRealPerformanceTest.java index 3867082..07c4c95 100644 --- a/tests/src/cgeo/geocaching/test/RegExRealPerformanceTest.java +++ b/tests/src/cgeo/geocaching/test/RegExRealPerformanceTest.java @@ -17,7 +17,7 @@ public class RegExRealPerformanceTest extends AndroidTestCase { public static void testRegEx() { - List<String> output = RegExPerformanceTest.doTheTests(10); + final List<String> output = RegExPerformanceTest.doTheTests(10); for (String s : output) { Log.d(s); diff --git a/tests/src/cgeo/geocaching/test/WhitespaceTest.java b/tests/src/cgeo/geocaching/test/WhitespaceTest.java index a78f2fa..6138755 100644 --- a/tests/src/cgeo/geocaching/test/WhitespaceTest.java +++ b/tests/src/cgeo/geocaching/test/WhitespaceTest.java @@ -57,10 +57,10 @@ public class WhitespaceTest extends AbstractResourceInstrumentationTestCase { } public void testRegex() { - Pattern pattern = Pattern.compile("\\s+"); + final Pattern pattern = Pattern.compile("\\s+"); final long start = System.currentTimeMillis(); - Matcher matcher = pattern.matcher(data); - String result = matcher.replaceAll(" ").trim(); + final Matcher matcher = pattern.matcher(data); + final String result = matcher.replaceAll(" ").trim(); final long end = System.currentTimeMillis(); assertEquals(EXPECTED_SIZE - 1, result.length()); Log.d((end - start) + " ms regex"); @@ -68,14 +68,14 @@ public class WhitespaceTest extends AbstractResourceInstrumentationTestCase { public void testReplaceAll() { final long start = System.currentTimeMillis(); - String result = data.replaceAll("\\s+", " "); + final String result = data.replaceAll("\\s+", " "); final long end = System.currentTimeMillis(); assertEquals(EXPECTED_SIZE + 1, result.length()); Log.d((end - start) + " ms replaceAll"); } public void testActualImplementation() { - String result; + final String result; final long start = System.currentTimeMillis(); result = BaseUtils.replaceWhitespace(data); final long end = System.currentTimeMillis(); @@ -84,7 +84,7 @@ public class WhitespaceTest extends AbstractResourceInstrumentationTestCase { } public void testManually() { - String result; + final String result; final long start = System.currentTimeMillis(); result = replaceWhitespaceManually(data); final long end = System.currentTimeMillis(); @@ -93,7 +93,7 @@ public class WhitespaceTest extends AbstractResourceInstrumentationTestCase { } public void testStringUtils() { - String result; + final String result; final long start = System.currentTimeMillis(); result = replaceWhitespaceStringUtils(data); final long end = System.currentTimeMillis(); diff --git a/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java b/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java index 035c7bc..6de8f4f 100644 --- a/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java +++ b/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java @@ -96,7 +96,7 @@ public class GC1ZXX2 extends MockedCache { @Override public List<String> getAttributes() { - String[] attributes = new String[] { + final String[] attributes = new String[] { "bicycles_yes", "available_yes", "stroller_yes", @@ -111,7 +111,7 @@ public class GC1ZXX2 extends MockedCache { @Override public Map<LogType, Integer> getLogCounts() { - Map<LogType, Integer> logCounts = new HashMap<LogType, Integer>(); + final Map<LogType, Integer> logCounts = new HashMap<LogType, Integer>(); logCounts.put(LogType.PUBLISH_LISTING, 1); logCounts.put(LogType.FOUND_IT, 368); logCounts.put(LogType.POST_REVIEWER_NOTE, 1); diff --git a/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java b/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java index a7722d4..107384f 100644 --- a/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java +++ b/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java @@ -130,7 +130,7 @@ public class GC2CJPF extends MockedCache { @Override public List<String> getAttributes() { - String[] attributes = new String[] { + final String[] attributes = new String[] { "motorcycles_no", "wheelchair_no", "winter_yes", @@ -147,7 +147,7 @@ public class GC2CJPF extends MockedCache { @Override public Map<LogType, Integer> getLogCounts() { - Map<LogType, Integer> logCounts = new HashMap<LogType, Integer>(); + final Map<LogType, Integer> logCounts = new HashMap<LogType, Integer>(); logCounts.put(LogType.PUBLISH_LISTING, 1); logCounts.put(LogType.FOUND_IT, 119); logCounts.put(LogType.DIDNT_FIND_IT, 3); diff --git a/tests/src/cgeo/geocaching/test/mock/GC3XX5J.java b/tests/src/cgeo/geocaching/test/mock/GC3XX5J.java index ca558ac..b598cfa 100644 --- a/tests/src/cgeo/geocaching/test/mock/GC3XX5J.java +++ b/tests/src/cgeo/geocaching/test/mock/GC3XX5J.java @@ -96,7 +96,7 @@ public class GC3XX5J extends MockedCache { @Override public List<String> getAttributes() { - String[] attributes = new String[] { + final String[] attributes = new String[] { "stroller_no", "kids_no", "bicycles_yes", @@ -114,7 +114,7 @@ public class GC3XX5J extends MockedCache { @Override public Map<LogType, Integer> getLogCounts() { - Map<LogType, Integer> logCounts = new HashMap<LogType, Integer>(); + final Map<LogType, Integer> logCounts = new HashMap<LogType, Integer>(); logCounts.put(LogType.PUBLISH_LISTING, 2); logCounts.put(LogType.FOUND_IT, 65); logCounts.put(LogType.RETRACT, 1); |
