keep around boost::move based rule cache for benchmarking purposes
This commit is contained in:
parent
a645eb9a21
commit
ce5c49d814
1 changed files with 78 additions and 8 deletions
|
@ -393,9 +393,74 @@ struct test8
|
|||
}
|
||||
};
|
||||
|
||||
#include <boost/container/vector.hpp>
|
||||
#include <mapnik/rule_cache.hpp>
|
||||
|
||||
#if BOOST_VERSION >= 105300
|
||||
#include <boost/container/vector.hpp>
|
||||
#include <boost/move/utility.hpp>
|
||||
|
||||
class rule_cache_move
|
||||
{
|
||||
private:
|
||||
BOOST_MOVABLE_BUT_NOT_COPYABLE(rule_cache_move)
|
||||
public:
|
||||
typedef std::vector<rule const*> 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_;
|
||||
|
@ -425,9 +490,9 @@ struct test9
|
|||
void operator()()
|
||||
{
|
||||
for (unsigned i=0;i<iter_;++i) {
|
||||
boost::container::vector<rule_cache> rule_caches;
|
||||
boost::container::vector<rule_cache_move> rule_caches;
|
||||
for (unsigned i=0;i<num_styles_;++i) {
|
||||
rule_cache rc;
|
||||
rule_cache_move rc;
|
||||
for (unsigned i=0;i<num_rules_;++i) {
|
||||
rc.add_rule(rules_[i]);
|
||||
}
|
||||
|
@ -437,11 +502,13 @@ struct test9
|
|||
}
|
||||
};
|
||||
|
||||
class rule_cache_old
|
||||
#endif
|
||||
|
||||
class rule_cache_heap
|
||||
{
|
||||
public:
|
||||
typedef std::vector<rule const*> rule_ptrs;
|
||||
rule_cache_old()
|
||||
rule_cache_heap()
|
||||
: if_rules_(),
|
||||
else_rules_(),
|
||||
also_rules_() {}
|
||||
|
@ -512,9 +579,9 @@ struct test10
|
|||
void operator()()
|
||||
{
|
||||
for (unsigned i=0;i<iter_;++i) {
|
||||
boost::ptr_vector<rule_cache_old> rule_caches;
|
||||
boost::ptr_vector<rule_cache_heap> rule_caches;
|
||||
for (unsigned i=0;i<num_styles_;++i) {
|
||||
std::auto_ptr<rule_cache_old> rc(new rule_cache_old);
|
||||
std::auto_ptr<rule_cache_heap> rc(new rule_cache_heap);
|
||||
for (unsigned i=0;i<num_rules_;++i) {
|
||||
rc->add_rule(rules_[i]);
|
||||
}
|
||||
|
@ -640,9 +707,12 @@ int main( int argc, char** argv)
|
|||
}
|
||||
|
||||
{
|
||||
// TODO - only run #if BOOST_VERSION >= 105300
|
||||
#if BOOST_VERSION >= 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
|
||||
}
|
||||
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue