diff options
author | Haavard <havardpe@yahoo-inc.com> | 2017-02-21 13:51:10 +0000 |
---|---|---|
committer | Haavard <havardpe@yahoo-inc.com> | 2017-02-21 13:51:10 +0000 |
commit | 0230a8968e7e08f3ddbfa9fad7114605252992cc (patch) | |
tree | 6bf095a6967d063d0bf58d8406ea47e7576c1ca4 /eval/src | |
parent | 942dad04d13bd85822bd622af5ba08572617f2cc (diff) |
also log lazy time/factor in explore benchmark
Diffstat (limited to 'eval/src')
-rw-r--r-- | eval/src/tests/eval/gbdt/gbdt_benchmark.cpp | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/eval/src/tests/eval/gbdt/gbdt_benchmark.cpp b/eval/src/tests/eval/gbdt/gbdt_benchmark.cpp index 1f8cde5b1bb..820b8ec692d 100644 --- a/eval/src/tests/eval/gbdt/gbdt_benchmark.cpp +++ b/eval/src/tests/eval/gbdt/gbdt_benchmark.cpp @@ -13,12 +13,15 @@ using namespace vespalib::eval; using namespace vespalib::eval::nodes; using namespace vespalib::eval::gbdt; +double budget = 2.0; + //----------------------------------------------------------------------------- struct CompileStrategy { virtual const char *name() const = 0; virtual const char *code_name() const = 0; virtual CompiledFunction compile(const Function &function) const = 0; + virtual CompiledFunction compile_lazy(const Function &function) const = 0; bool is_same(const CompileStrategy &rhs) const { return (this == &rhs); } @@ -26,41 +29,50 @@ struct CompileStrategy { }; struct NullStrategy : CompileStrategy { - virtual const char *name() const { + const char *name() const override { return "none"; } - virtual const char *code_name() const { + const char *code_name() const override { return "Optimize::none"; } - virtual CompiledFunction compile(const Function &function) const { + CompiledFunction compile(const Function &function) const override { return CompiledFunction(function, PassParams::ARRAY, Optimize::none); } + CompiledFunction compile_lazy(const Function &function) const override { + return CompiledFunction(function, PassParams::LAZY, Optimize::none); + } }; NullStrategy none; struct VMForestStrategy : CompileStrategy { - virtual const char *name() const { + const char *name() const override { return "vm-forest"; } - virtual const char *code_name() const { + const char *code_name() const override { return "VMForest::optimize_chain"; } - virtual CompiledFunction compile(const Function &function) const { + CompiledFunction compile(const Function &function) const override { return CompiledFunction(function, PassParams::ARRAY, VMForest::optimize_chain); } + CompiledFunction compile_lazy(const Function &function) const override { + return CompiledFunction(function, PassParams::LAZY, VMForest::optimize_chain); + } }; VMForestStrategy vm_forest; struct DeinlineForestStrategy : CompileStrategy { - virtual const char *name() const { + const char *name() const override { return "deinline-forest"; } - virtual const char *code_name() const { + const char *code_name() const override { return "DeinlineForest::optimize_chain"; } - virtual CompiledFunction compile(const Function &function) const { + CompiledFunction compile(const Function &function) const override { return CompiledFunction(function, PassParams::ARRAY, DeinlineForest::optimize_chain); } + CompiledFunction compile_lazy(const Function &function) const override { + return CompiledFunction(function, PassParams::LAZY, DeinlineForest::optimize_chain); + } }; DeinlineForestStrategy deinline_forest; @@ -72,6 +84,7 @@ struct Option { bool is_same(const Option &rhs) const { return strategy.is_same(rhs.strategy); } const char *name() const { return strategy.name(); } CompiledFunction compile(const Function &function) const { return strategy.compile(function); } + CompiledFunction compile_lazy(const Function &function) const { return strategy.compile_lazy(function); } const char *code_name() const { return strategy.code_name(); } }; @@ -153,11 +166,14 @@ std::vector<Option> find_order(const ForestParams ¶ms, Function forest = make_forest(params, num_trees); for (size_t i = 0; i < options.size(); ++i) { CompiledFunction compiled_function = options[i].compile(forest); + CompiledFunction compiled_function_lazy = options[i].compile_lazy(forest); std::vector<double> inputs(compiled_function.num_params(), 0.5); - results.push_back({compiled_function.estimate_cost_us(inputs), i}); - fprintf(stderr, " %20s@%6zu: %16g us (inputs: %zu)\n", + results.push_back({compiled_function.estimate_cost_us(inputs, budget), i}); + double lazy_time = compiled_function_lazy.estimate_cost_us(inputs, budget); + double lazy_factor = lazy_time / results.back().us; + fprintf(stderr, " %20s@%6zu: %16g us (inputs: %zu) [lazy: %g us, factor: %g]\n", options[i].name(), num_trees, results.back().us, - inputs.size()); + inputs.size(), lazy_time, lazy_factor); } std::sort(results.begin(), results.end()); std::vector<Option> ret; |