Created
February 14, 2018 17:29
-
-
Save lopex/08ecc5226c4dc4e420a4144aab893976 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.joni.benchmark; | |
import org.jcodings.specific.ASCIIEncoding; | |
import org.joni.Matcher; | |
import org.joni.Option; | |
import org.joni.Regex; | |
import org.joni.Syntax; | |
import org.joni.WarnCallback; | |
import org.openjdk.jmh.annotations.Benchmark; | |
import org.openjdk.jmh.annotations.Scope; | |
import org.openjdk.jmh.annotations.State; | |
public class JoniBenchmark { | |
@State(Scope.Benchmark) | |
public static class RState { | |
byte str[] = "this is a test".getBytes(); | |
byte pattern[] = "\\A[[:space:]]*\\z".getBytes(); | |
Regex regex = new Regex(pattern, 0, pattern.length, Option.NONE, ASCIIEncoding.INSTANCE, Syntax.RUBY, | |
WarnCallback.DEFAULT); | |
int result; | |
} | |
@Benchmark | |
public void testMethod(RState state) { | |
Matcher matcher = state.regex.matcher(state.str); | |
matcher.search(0, state.str.length, Option.NONE); // Option.CR_7_BIT; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment