Class RegexProfile
java.lang.Object
com.oracle.truffle.regex.RegexProfile
This profile is used for tracking statistics about a compiled regular expression, such as the
amount of times the expression was executed and the amount of matches that were found. The
profiling information is used by TRegex for deciding whether a regular expression should match
capture groups in a lazy or eager way.
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanCheck if the profiling information gathered so far is sufficient for making a decision.voidincCalls()Increase the number of times the regular expression was executed by one.voidIncrease the number of times a match for the regular expression was found by one.voidincProcessedCharacters(int numberOfCharacters) voidprofileCaptureGroupAccess(int matchLength, int numberOfCharsTraversed) Update profile after the execution of a lazy capture groups search DFA.voidbooleanshouldGenerateDFA(int inputLength) Decides whether the regular expression was executed often enough or would process enough characters to warrant the costly generation of a fully expanded DFA.booleanDecides whether the capture groups of the regular expression should be matched in an eager manner.toString()
-
Constructor Details
-
RegexProfile
public RegexProfile()
-
-
Method Details
-
incCalls
public void incCalls()Increase the number of times the regular expression was executed by one. -
resetCalls
public void resetCalls() -
incMatches
public void incMatches()Increase the number of times a match for the regular expression was found by one. -
profileCaptureGroupAccess
public void profileCaptureGroupAccess(int matchLength, int numberOfCharsTraversed) Update profile after the execution of a lazy capture groups search DFA.- Parameters:
matchLength- the length of capture group 0 of the match.numberOfCharsTraversed- the number of characters that were traversed between the initial index (fromIndex) and the end of the match.- See Also:
-
atEvaluationTripPoint
public boolean atEvaluationTripPoint()Check if the profiling information gathered so far is sufficient for making a decision.- Returns:
trueif the number of times the regular expression was called is divisible by 90.
-
shouldGenerateDFA
public boolean shouldGenerateDFA(int inputLength) Decides whether the regular expression was executed often enough or would process enough characters to warrant the costly generation of a fully expanded DFA. -
incProcessedCharacters
public void incProcessedCharacters(int numberOfCharacters) -
shouldUseEagerMatching
public boolean shouldUseEagerMatching()Decides whether the capture groups of the regular expression should be matched in an eager manner.- Returns:
trueif:- most searches led to a match
- the capture groups of most search results were queried
- the match often covered a big part of the part of the input string that had to be traversed in order to find it.
-
toString
-