-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Significant performance degradation of Poco::DateTimeParser #4592
Comments
Yeah, well - it's either that or we silently accept garbage, as we used to. If you have an improvement proposal, send a PR |
bool DateTimeFormat::isValid(const std::string& dateTime)
{
static const RegularExpression regs[] = {
RegularExpression(DateTimeFormat::ISO8601_REGEX),
RegularExpression(DateTimeFormat::RFC822_REGEX),
RegularExpression(DateTimeFormat::RFC1123_REGEX),
RegularExpression(DateTimeFormat::HTTP_REGEX),
RegularExpression(DateTimeFormat::RFC850_REGEX),
RegularExpression(DateTimeFormat::RFC1036_REGEX),
RegularExpression(DateTimeFormat::ASCTIME_REGEX),
RegularExpression(DateTimeFormat::SORTABLE_REGEX)
};
for (const auto& f : regs)
{
if (f.match(dateTime)) return true;
}
return false;
} Creating the |
Why are all regexes checked, and not just one? E.g. for the following code
I would expect that only |
About handling garbage input. Let's consider the following code: poco/Foundation/src/DateTimeParser.cpp Lines 108 to 110 in 4f1cf68
poco/Foundation/src/DateTimeParser.cpp Lines 25 to 26 in 4f1cf68
poco/Foundation/src/DateTimeParser.cpp Lines 37 to 38 in 4f1cf68
Points for discussion:
I hope the parser body can be improved so that it is more strict and regular expressions can be avoided. |
@andrewauclair can you look at this issue and propose improvements? |
Consider the following code:
Execution time (Release configuration):
With the format
Poco::DateTimeFormat::ISO8601_FRAC_FORMAT + " "
(with an additional space) execution time becomes better for 1.13.3.I guess the reason is the following commit: 4f1cf68 (#4330).
Up to 8 regex expressions are compiled on each call
poco/Foundation/src/DateTimeFormat.cpp
Lines 153 to 156 in 4f1cf68
if the provided format is known:
poco/Foundation/src/DateTimeParser.cpp
Line 47 in 4f1cf68
The text was updated successfully, but these errors were encountered: