Skip to content

Instantly share code, notes, and snippets.

@lopex
Created February 14, 2018 17:29
Show Gist options
  • Save lopex/08ecc5226c4dc4e420a4144aab893976 to your computer and use it in GitHub Desktop.
Save lopex/08ecc5226c4dc4e420a4144aab893976 to your computer and use it in GitHub Desktop.
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