Skip to content

Instantly share code, notes, and snippets.

@ecki ecki/re-find.diff
Created Aug 22, 2014

Embed
What would you like to do?
JMH Patch for RE pattern matching
diff -r 0d74d2f85299 jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java Wed Aug 20 16:23:00 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java Fri Aug 22 02:36:54 2014 +0200
@@ -85,7 +85,7 @@
}
/**
- * Gets all the micro benchmarks that matches the given regexp, sorted
+ * Gets all the micro benchmarks that matches the given regexp, sorted.
*
* @param out Output the messages here
* @param regexps List of regexps to match against
@@ -109,7 +109,7 @@
excludePatterns.add(Pattern.compile(regexp));
}
- // find all benchmarks matching pattern
+ // find all benchmarks containing pattern
SortedSet<BenchmarkListEntry> result = new TreeSet<BenchmarkListEntry>();
try {
for (Reader r : getReaders()) {
@@ -129,12 +129,12 @@
BenchmarkListEntry br = new BenchmarkListEntry(line);
for (Pattern pattern : includePatterns) {
- if (pattern.matcher(br.getUsername()).matches()) {
+ if (pattern.matcher(br.getUsername()).find()) {
boolean exclude = false;
// excludes override
for (Pattern excludePattern : excludePatterns) {
- if (excludePattern.matcher(line).matches()) {
+ if (excludePattern.matcher(line).find()) {
out.verbosePrintln("Excluding " + br.getUsername() + ", matches " + excludePattern);
exclude = true;
diff -r 0d74d2f85299 jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkList.java
--- a/jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkList.java Wed Aug 20 16:23:00 2014 +0400
+++ b/jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkList.java Fri Aug 22 02:36:54 2014 +0200
@@ -25,23 +25,21 @@
package org.openjdk.jmh.runner;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import org.openjdk.jmh.runner.format.OutputFormat;
import org.openjdk.jmh.runner.format.OutputFormatFactory;
import org.openjdk.jmh.runner.options.VerboseMode;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.Set;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
/**
* Tests for BenchmarkList
*/
-@Ignore
public class TestBenchmarkList {
private static BenchmarkList list;
@@ -73,14 +71,40 @@
}
@Test
- public void testListFindSingle() throws Exception {
- // check find without excldues
+ public void testListFindSingleByPattern() throws Exception {
+ // check find without excludes
excludes.clear();
Set<BenchmarkListEntry> micros = list.find(out, ".*Hash.*", excludes);
assertEquals(7, micros.size());
}
@Test
+ public void testListFindSingleBySubstring() throws Exception {
+ // check find without excludes
+ excludes.clear();
+ Set<BenchmarkListEntry> micros = list.find(out, "Hash", excludes);
+ assertEquals(7, micros.size());
+ }
+
+ @Test
+ public void testListFindSingleByTypical() throws Exception {
+ // check find without excludes
+ excludes.clear();
+ // this would be a typical partial pattern with . abuse case
+ Set<BenchmarkListEntry> micros = list.find(out, "jbb05.GeneratedSPECjbb2005HashMap", excludes);
+ assertEquals(5, micros.size());
+ }
+
+ @Test
+ public void testListFindAnchored() throws Exception {
+ // check find without excludes
+ excludes.clear();
+ // matches only: org.openjdk.jmh.runner.TestMicro.dummy
+ Set<BenchmarkListEntry> micros = list.find(out, "^org\\.openjdk.*\\.dummy$", excludes);
+ assertEquals(1, micros.size());
+ }
+
+ @Test
public void testListFindSingleWithExcludes() throws Exception {
// check find with excludes
excludes.clear();
@@ -90,6 +114,41 @@
}
@Test
+ public void testListFindAllWithSubstringExclude() throws Exception {
+ // check find with excludes
+ excludes.clear();
+ excludes.add("oracle");
+ Set<BenchmarkListEntry> micros = list.find(out, "", excludes);
+ assertEquals(10, micros.size());
+ }
+
+ @Test
+ public void testListFindAllWithEmpty() throws Exception {
+ // will get modified
+ List<String> emptyIncludes = new ArrayList<String>();
+ excludes.clear();
+ Set<BenchmarkListEntry> micros = list.find(out, emptyIncludes, excludes);
+ assertEquals(20, micros.size());
+ }
+
+ @Test
+ public void testListFindIncludeList() throws Exception {
+ // check find with excludes
+ excludes.clear();
+ List<String> includes = Arrays.asList("^oracle", ".*openjmh.*");
+ Set<BenchmarkListEntry> micros = list.find(out, includes, excludes);
+ assertEquals(10, micros.size());
+ }
+
+ @Test
+ public void testListFindWithIncludesAndExcludes() throws Exception {
+ excludes.clear();
+ excludes.add(".*Int.*");
+ Set<BenchmarkListEntry> micros = list.find(out, ".*Concurrent.*", excludes);
+ assertEquals(2, micros.size());
+ }
+
+ @Test
public void testListIsSorted() throws Exception {
// micros should be sorted
excludes.clear();
@@ -98,12 +157,4 @@
BenchmarkListEntry first = micros.iterator().next();
assertTrue("oracle.micro.benchmarks.api.java.util.concurrent.GeneratedMaps.testConcurrentHashMap".equals(first.getUsername()));
}
-
- @Test
- public void testListGetWithIncludesAndExcludes() throws Exception {
- excludes.clear();
- excludes.add(".*Int.*");
- Set<BenchmarkListEntry> micros = list.find(out, ".*Concurrent.*", excludes);
- assertEquals(2, micros.size());
- }
}
diff -r 0d74d2f85299 jmh-core/src/test/resources/org/openjdk/jmh/runner/MicroBenchmarks
--- a/jmh-core/src/test/resources/org/openjdk/jmh/runner/MicroBenchmarks Wed Aug 20 16:23:00 2014 +0400
+++ b/jmh-core/src/test/resources/org/openjdk/jmh/runner/MicroBenchmarks Fri Aug 22 02:36:54 2014 +0200
@@ -22,23 +22,26 @@
# questions.
#
-oracle.micro.benchmarks.api.java.util.concurrent.NormalMaps.testConcurrentHashMap, xxx, AverageTime, 1=
-oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap.jbb2005HashMapGetInt, xxx, AverageTime, 1=
-oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap.jbb2005HashMapGetIntGC, xxx, AverageTime, 1=
-oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap.jbb2005HashMapGetInteger, xxx, AverageTime, 1=
-oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap.jbb2005ResizedHashMapGetInt, xxx, AverageTime, 1=
-oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap.jbb2005ResizedHashMapGetInteger, xxx, AverageTime, 1=
-oracle.micro.benchmarks.app.sjent.GeneratedPrintBase64.printBase64Binary_128bytes, xxx, AverageTime, 1=
-oracle.micro.benchmarks.app.sjent.GeneratedPrintBase64.printBase64Binary_32bytes, xxx, AverageTime, 1=
-oracle.micro.benchmarks.app.sjent.GeneratedPrintBase64.printBase64Binary_512bytes, xxx, AverageTime, 1=
-oracle.micro.benchmarks.api.java.util.concurrent.GeneratedMaps.testConcurrentHashMap, xxx, AverageTime, 1=
-org.openjdk.jmh.runner.TestMicro.dummy, xxx, AverageTime, 1=
-org.openjdk.jmh.runner.TestMicro.dummyWarm, xxx, AverageTime, 1=
-org.openjdk.jmh.runner.TestMicro.dummyWarmOnly, xxx, AverageTime, 1=
-org.openjdk.jmh.runner.TestMicro.dummySetupPayload, xxx, AverageTime, 1=
-org.openjdk.jmh.runner.TestMicro.boom_Exception, xxx, AverageTime, 1=
-org.openjdk.jmh.runner.TestMicro.boom_Error, xxx, AverageTime, 1=
-org.openjdk.jmh.runner.TestMicro.boom_Throwable, xxx, AverageTime, 1=
-org.openjdk.jmh.runner.TestMicro.blackholed, xxx, AverageTime, 1=
-org.openjdk.jmh.runner.TestBrokenMicro.dummyPayload, xxx, AverageTime, 1=
-org.openjdk.jmh.runner.TestExceptionThrowingMicro.ouch, xxx, AverageTime, 1=
+
+oracle.micro.benchmarks.api.java.util.concurrent.NormalMaps.testConcurrentHashMap===,===oracle.micro.benchmarks.api.java.util.concurrent.generated.NormalMaps.testConcurrentHashMap===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]
+oracle.micro.benchmarks.api.java.util.concurrent.NormalMaps.testConcurrentHashMap===,===oracle.micro.benchmarks.api.java.util.concurrent.generated.NormalMaps.testConcurrentHashMapThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]
+oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap.jbb2005HashMapGetInt===,===oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap.jbb2005HashMapGetIntThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]
+oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap.jbb2005HashMapGetIntGC===,===oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap.jbb2005HashMapGetIntGCThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]
+oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap.jbb2005HashMapGetInteger===,===oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap.jbb2005HashMapGetIntegerThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]
+oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap.jbb2005ResizedHashMapGetInt===,===oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap.jbb2005ResizedHashMapGetIntThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]
+oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap.jbb2005ResizedHashMapGetInteger===,===oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap.jbb2005ResizedHashMapGetIntegerThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]
+oracle.micro.benchmarks.app.sjent.GeneratedPrintBase64.printBase64Binary_128bytes===,===oracle.micro.benchmarks.app.sjent.generated.GeneratedPrintBase64.printBase64Binary_128bytesThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]
+oracle.micro.benchmarks.app.sjent.GeneratedPrintBase64.printBase64Binary_32bytes===,===oracle.micro.benchmarks.app.sjent.generated.GeneratedPrintBase64.printBase64Binary_32bytesThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]
+oracle.micro.benchmarks.app.sjent.GeneratedPrintBase64.printBase64Binary_512bytes===,===oracle.micro.benchmarks.app.sjent.generated.GeneratedPrintBase64.printBase64Binary_512bytesThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]
+oracle.micro.benchmarks.api.java.util.concurrent.GeneratedMaps.testConcurrentHashMap===,===oracle.micro.benchmarks.api.java.util.concurrent.generated.GeneratedMaps.testConcurrentHashMapThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]
+
+org.openjdk.jmh.runner.TestMicro.dummy===,===org.openjdk.jmh.runner.generated.TestMicro.dummyThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]
+org.openjdk.jmh.runner.TestMicro.dummyWarm===,===org.openjdk.jmh.runner.generated.TestMicro.dummyWarmThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]
+org.openjdk.jmh.runner.TestMicro.dummyWarmOnly===,===org.openjdk.jmh.runner.generated.TestMicro.dummyWarmOnlyThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]
+org.openjdk.jmh.runner.TestMicro.dummySetupPayload===,===org.openjdk.jmh.runner.generated.TestMicro.dummySetupPayloadThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]
+org.openjdk.jmh.runner.TestMicro.boom_Exception===,===org.openjdk.jmh.runner.generated.TestMicro.boom_ExceptionThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]
+org.openjdk.jmh.runner.TestMicro.boom_Error===,===org.openjdk.jmh.runner.generated.TestMicro.boom_ErrorThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]
+org.openjdk.jmh.runner.TestMicro.boom_Throwable===,===org.openjdk.jmh.runner.generated.TestMicro.boom_ThrowableThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]
+org.openjdk.jmh.runner.TestMicro.blackholed===,===org.openjdk.jmh.runner.generated.TestMicro.blackholedThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]
+org.openjdk.jmh.runner.TestBrokenMicro.dummyPayload===,===org.openjdk.jmh.runner.generated.TestBrokenMicro.dummyPayloadThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]
+org.openjdk.jmh.runner.TestExceptionThrowingMicro.ouch===,===org.openjdk.jmh.runner.generated.TestExceptionThrowingMicro.ouchThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.