Last active
November 27, 2020 16:18
-
-
Save jamie-mcilroy/d557f76c6d0290ce9efcf15c9508e94a to your computer and use it in GitHub Desktop.
test regex for speed
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
@Test | |
void testTeamRegex() { | |
String expectedStringToFind ="{status: Running, ballpos: -0.0375, distance: 1.143484}"; | |
String sfeed = "efewfewfew{status: Running, ballpos: -0.0375, distance: 1.143484}dweewdew"; | |
long startTime = System.currentTimeMillis(); | |
Pattern localPattern = Pattern.compile("\\{.*\\}" ); | |
Matcher matcher = localPattern.matcher(sfeed); | |
matcher.toMatchResult(); | |
assertTrue(matcher.find()); | |
assertEquals(expectedStringToFind, matcher.group()); | |
long endTime = System.currentTimeMillis(); | |
long totalTime = endTime-startTime; | |
assertTrue(totalTime<10); | |
System.out.println("testTeamRegex Time to run (in ms): " + totalTime); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment