diff --git a/benchmark/data/polygon.wkt b/benchmark/data/polygon.wkt index 2fe5b480a..b31735f6a 100644 --- a/benchmark/data/polygon.wkt +++ b/benchmark/data/polygon.wkt @@ -1 +1 @@ -MULTIPOLYGON (((30 20, 10 40, 45 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5))) \ No newline at end of file +POLYGON ((155 203, 233 454, 315 340, 421 446, 463 324, 559 466, 665 253, 528 178, 394 229, 329 138, 212 134, 183 228, 200 264, 155 203),(313 190, 440 256, 470 248, 510 305, 533 237, 613 263, 553 397, 455 262, 405 378, 343 287, 249 334, 229 191, 313 190)) diff --git a/benchmark/run.cpp b/benchmark/run.cpp index 6173f6758..29b4ba235 100644 --- a/benchmark/run.cpp +++ b/benchmark/run.cpp @@ -14,7 +14,6 @@ #include #include - // boost #include #include @@ -409,205 +408,6 @@ struct test8 } }; -#include - -#if BOOST_VERSION >= 105300 -#include -#include - -class rule_cache_move -{ -private: - BOOST_MOVABLE_BUT_NOT_COPYABLE(rule_cache_move) -public: - typedef std::vector rule_ptrs; - rule_cache_move() - : if_rules_(), - else_rules_(), - also_rules_() {} - - rule_cache_move(BOOST_RV_REF(rule_cache_move) rhs) // move ctor - : if_rules_(boost::move(rhs.if_rules_)), - else_rules_(boost::move(rhs.else_rules_)), - also_rules_(boost::move(rhs.also_rules_)) - {} - - rule_cache_move& operator=(BOOST_RV_REF(rule_cache_move) rhs) // move assign - { - std::swap(if_rules_, rhs.if_rules_); - std::swap(else_rules_,rhs.else_rules_); - std::swap(also_rules_, rhs.also_rules_); - return *this; - } - - void add_rule(rule const& r) - { - if (r.has_else_filter()) - { - else_rules_.push_back(&r); - } - else if (r.has_also_filter()) - { - also_rules_.push_back(&r); - } - else - { - if_rules_.push_back(&r); - } - } - - rule_ptrs const& get_if_rules() const - { - return if_rules_; - } - - rule_ptrs const& get_else_rules() const - { - return else_rules_; - } - - rule_ptrs const& get_also_rules() const - { - return also_rules_; - } - -private: - rule_ptrs if_rules_; - rule_ptrs else_rules_; - rule_ptrs also_rules_; -}; - -struct test9 -{ - unsigned iter_; - unsigned threads_; - unsigned num_rules_; - unsigned num_styles_; - std::vector rules_; - explicit test9(unsigned iterations, - unsigned threads, - unsigned num_rules, - unsigned num_styles) : - iter_(iterations), - threads_(threads), - num_rules_(num_rules), - num_styles_(num_styles), - rules_() { - mapnik::rule r("test"); - for (unsigned i=0;i rule_caches; - for (unsigned i=0;i rule_ptrs; - rule_cache_heap() - : if_rules_(), - else_rules_(), - also_rules_() {} - - void add_rule(rule const& r) - { - if (r.has_else_filter()) - { - else_rules_.push_back(&r); - } - else if (r.has_also_filter()) - { - also_rules_.push_back(&r); - } - else - { - if_rules_.push_back(&r); - } - } - - rule_ptrs const& get_if_rules() const - { - return if_rules_; - } - - rule_ptrs const& get_else_rules() const - { - return else_rules_; - } - - rule_ptrs const& get_also_rules() const - { - return also_rules_; - } - -private: - rule_ptrs if_rules_; - rule_ptrs else_rules_; - rule_ptrs also_rules_; -}; - -struct test10 -{ - unsigned iter_; - unsigned threads_; - unsigned num_rules_; - unsigned num_styles_; - std::vector rules_; - explicit test10(unsigned iterations, - unsigned threads, - unsigned num_rules, - unsigned num_styles) : - iter_(iterations), - threads_(threads), - num_rules_(num_rules), - num_styles_(num_styles), - rules_() { - mapnik::rule r("test"); - for (unsigned i=0;i rule_caches; - for (unsigned i=0;i rc(new rule_cache_heap); - for (unsigned i=0;iadd_rule(rules_[i]); - } - rule_caches.push_back(rc); - } - } - } -}; - - #include #include "agg_conv_clipper.h" #include "agg_path_storage.h" @@ -648,18 +448,19 @@ struct test11 ps.line_to(extent_.maxx(), extent_.maxy()); ps.line_to(extent_.maxx(), extent_.miny()); ps.close_polygon(); - for (unsigned i=0;i= 105300 - test9 runner(1000,10,200,50); - benchmark(runner,"rule caching using boost::move"); -#else - std::clog << "not running: 'rule caching using boost::move'\n"; -#endif - } + // TODO - consider bring back rule cache benchmarks after c++11 is in master + // previously test 9/10 - { - test10 runner(1000,10,200,50); - benchmark(runner,"rule caching using heap allocation"); - } + // polygon/rect clipping + // IN : POLYGON ((155 203, 233 454, 315 340, 421 446, 463 324, 559 466, 665 253, 528 178, 394 229, 329 138, 212 134, 183 228, 200 264, 155 203),(313 190, 440 256, 470 248, 510 305, 533 237, 613 263, 553 397, 455 262, 405 378, 343 287, 249 334, 229 191, 313 190)) + // RECT : POLYGON ((181 106, 181 470, 631 470, 631 106, 181 106)) + // OUT (expected) + // POLYGON ((181 286.6666666666667, 233 454, 315 340, 421 446, 463 324, 559 466, 631 321.3207547169811, 631 234.38686131386862, 528 178, 394 229, 329 138, 212 134, 183 228, 200 264, 181 238.24444444444444, 181 286.6666666666667),(313 190, 440 256, 470 248, 510 305, 533 237, 613 263, 553 397, 455 262, 405 378, 343 287, 249 334, 229 191, 313 190)) + mapnik::box2d clipping_box(181,106,631,470); { std::string filename_("benchmark/data/polygon.wkt"); std::ifstream in(filename_.c_str(),std::ios_base::in | std::ios_base::binary); @@ -879,23 +676,19 @@ int main( int argc, char** argv) throw std::runtime_error("could not open: '" + filename_ + "'"); std::string wkt_in( (std::istreambuf_iterator(in) ), (std::istreambuf_iterator()) ); - mapnik::box2d clipping_box(0,0,40,40); - - test11 runner(100000,10,wkt_in,clipping_box); + test11 runner(10000,10,wkt_in,clipping_box); benchmark(runner,"clipping polygon with agg_conv_clipper"); } { - std::string filename_("benchmark/data/polygon.wkt"); std::ifstream in(filename_.c_str(),std::ios_base::in | std::ios_base::binary); if (!in.is_open()) throw std::runtime_error("could not open: '" + filename_ + "'"); std::string wkt_in( (std::istreambuf_iterator(in) ), (std::istreambuf_iterator()) ); - mapnik::box2d clipping_box(0,0,40,40); - test12 runner(100000,10,wkt_in,clipping_box); + test12 runner(10000,10,wkt_in,clipping_box); benchmark(runner,"clipping polygon with mapnik::polygon_clipper"); }