diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2017-08-27 13:56:24 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2017-08-27 14:03:20 -0400 |
commit | c6cf5ec6ae6420e902441289a5b7524a2322a664 (patch) | |
tree | 537a21dd534b83948b7e0de38e90ebf2f2fdb95e /bfs.h | |
parent | 8a9b6497167626e768cab063e9d6c381523b3244 (diff) | |
download | bfs-c6cf5ec6ae6420e902441289a5b7524a2322a664.tar.xz |
Implement cost-based optimization
Diffstat (limited to 'bfs.h')
-rw-r--r-- | bfs.h | 21 |
1 files changed, 16 insertions, 5 deletions
@@ -62,16 +62,18 @@ typedef bool eval_fn(const struct expr *expr, struct eval_state *state); * Various debugging flags. */ enum debug_flags { + /** Print cost estimates. */ + DEBUG_COST = 1 << 0, /** Print executed command details. */ - DEBUG_EXEC = 1 << 0, + DEBUG_EXEC = 1 << 1, /** Print optimization details. */ - DEBUG_OPT = 1 << 1, + DEBUG_OPT = 1 << 2, /** Print rate information. */ - DEBUG_RATES = 1 << 2, + DEBUG_RATES = 1 << 3, /** Trace all stat() calls. */ - DEBUG_STAT = 1 << 3, + DEBUG_STAT = 1 << 4, /** Print the parse tree. */ - DEBUG_TREE = 1 << 4, + DEBUG_TREE = 1 << 5, }; /** @@ -212,6 +214,10 @@ struct expr { /** Whether this expression always evaluates to false. */ bool always_false; + /** Estimated cost. */ + double cost; + /** Estimated probability of success. */ + double probability; /** Number of times this predicate was executed. */ size_t evaluations; /** Number of times this predicate succeeded. */ @@ -274,6 +280,11 @@ struct expr { bool expr_never_returns(const struct expr *expr); /** + * @return The result of the comparison for this expression. + */ +bool expr_cmp(const struct expr *expr, long long n); + +/** * Parse the command line. */ struct cmdline *parse_cmdline(int argc, char *argv[]); |