Created
December 22, 2015 16:50
-
-
Save lennartkoopmann/1419e7887ba40161a38c to your computer and use it in GitHub Desktop.
This file contains hidden or 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() { | |
VERY_DESCRIPTIVE.matcher(MESSAGE).matches(); | |
} | |
@Benchmark | |
public void descriptiveMatch() { | |
DESCRIPTIVE.matcher(MESSAGE).matches(); | |
} | |
@Benchmark | |
public void openMatch() { | |
OPEN.matcher(MESSAGE).matches(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment