Skip to content
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

Merged
merged 10 commits into from
Jan 28, 2021
Merged

Implement formula evaluator #18

merged 10 commits into from
Jan 28, 2021

Conversation

nsmith-
Copy link
Collaborator

@nsmith- nsmith- commented Jan 28, 2021

@nsmith- nsmith- force-pushed the formula branch 2 times, most recently from f770645 to 9e17983 Compare January 28, 2021 07:36
@nsmith- nsmith- merged commit be611df into master Jan 28, 2021
@nsmith- nsmith- deleted the formula branch January 28, 2021 08:14
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

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?

Copy link
Collaborator Author

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...

Copy link
Collaborator Author

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)

Copy link
Collaborator Author

@nsmith- nsmith- Jan 28, 2021

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 {

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants