Last active
December 27, 2015 11:18
-
-
Save lennartkoopmann/1fc4d669c1f320ea9925 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
@State(Scope.Benchmark) | |
@BenchmarkMode(Mode.AverageTime) | |
@OutputTimeUnit(TimeUnit.MICROSECONDS) | |
public class DateRegexBenchmark { | |
private static final String MESSAGE = "2015-12-15T07:36:25+00:00 sundaysister kernel[0]: **** [IOBluetoothHostControllerUSBTransport][ClearFeatureInterruptEndpointHalt] -- successfully posting another read for the mInt0InterruptPipe -- mInterruptPipeInOutstandingIOCount = 1 -- this = 0xb800"; | |
private static Pattern VERY_DESCRIPTIVE; | |
private static Pattern DESCRIPTIVE; | |
private static Pattern OPEN; | |
@Setup | |
public void prepare() { | |
VERY_DESCRIPTIVE = Pattern.compile("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\+\\d{2}:\\d{2}"); | |
DESCRIPTIVE = Pattern.compile(".{4}-.{2}-.{2}T.{2}:.{2}:.{2}\\+.{2}:.{2}"); | |
OPEN = Pattern.compile(".*-.*-.*T.*:.*:.*\\+"); | |
} | |
@Benchmark | |
public void veryDescriptiveMatch(Blackhole bh) { | |
bh.consume(VERY_DESCRIPTIVE.matcher(MESSAGE).matches()); | |
} | |
@Benchmark | |
public void descriptiveMatch(Blackhole bh) { | |
bh.consume(DESCRIPTIVE.matcher(MESSAGE).matches()); | |
} | |
@Benchmark | |
public void openMatch(Blackhole bh) { | |
bh.consume(OPEN.matcher(MESSAGE).matches()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment