-
Notifications
You must be signed in to change notification settings - Fork 25
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
Implement formula evaluator #18
Conversation
On the demo example, parser is 100x faster than TFormula Evaluator 2x faster
f770645
to
9e17983
Compare
std::vector<int> variableIdx_; | ||
|
||
static std::map<ParserType, peg::parser> parsers_; | ||
static std::mutex parsers_mutex_; // could be one per parser, but this is good enough |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you done large scale threading tests to see how this affect performance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, but I hope the number of Formulas to compile is << the number of evaluations, so such contention is rare. Unless someone is doing something disgusting like re-loading the data each event...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Further, the number of parsers is very small (currently 1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the map is more or less pointless: if I wrapped the peg::parser with a shim class I could construct that as a static const member, rather than having the grammar text be the static const member.
throw std::runtime_error("Unrecognized AST node"); | ||
} | ||
|
||
double Formula::evaluate(const std::vector<Variable>& inputs, const std::vector<Variable::Type>& values) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inputs does not appear to be used.
Following https://github.com/nsmith-/correctionlib/discussions/17#discussioncomment-315714