2013-11-15 07:11:21 +00:00
|
|
|
#include "bench_framework.hpp"
|
|
|
|
#include <mapnik/unicode.hpp>
|
2015-12-02 14:32:55 +00:00
|
|
|
#include <mapnik/attribute.hpp>
|
2013-11-15 07:11:21 +00:00
|
|
|
#include <mapnik/expression.hpp>
|
|
|
|
#include <mapnik/expression_string.hpp>
|
|
|
|
|
|
|
|
class test : public benchmark::test_case
|
|
|
|
{
|
|
|
|
std::string expr_;
|
|
|
|
public:
|
|
|
|
test(mapnik::parameters const& params)
|
|
|
|
: test_case(params),
|
2014-04-30 01:25:21 +00:00
|
|
|
expr_("((([mapnik::geometry_type]=2) and ([oneway]=1)) and ([class]='path'))") {}
|
2013-11-15 07:11:21 +00:00
|
|
|
bool validate() const
|
|
|
|
{
|
2014-10-21 05:20:04 +00:00
|
|
|
mapnik::expression_ptr expr = mapnik::parse_expression(expr_);
|
2014-04-30 01:25:21 +00:00
|
|
|
std::string result = mapnik::to_expression_string(*expr);
|
|
|
|
bool ret = (result == expr_);
|
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
std::clog << result << " != " << expr_ << "\n";
|
|
|
|
}
|
|
|
|
return ret;
|
2013-11-15 07:11:21 +00:00
|
|
|
}
|
2014-12-12 16:59:45 +00:00
|
|
|
bool operator()() const
|
2013-11-15 07:11:21 +00:00
|
|
|
{
|
|
|
|
for (std::size_t i=0;i<iterations_;++i) {
|
2014-10-21 05:20:04 +00:00
|
|
|
mapnik::expression_ptr expr = mapnik::parse_expression(expr_);
|
2013-11-15 07:11:21 +00:00
|
|
|
}
|
2014-12-12 16:59:45 +00:00
|
|
|
return true;
|
2013-11-15 07:11:21 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
mapnik::parameters params;
|
|
|
|
benchmark::handle_args(argc,argv,params);
|
|
|
|
test test_runner(params);
|
2015-09-14 13:01:32 +00:00
|
|
|
return run(test_runner,"expr parsing");
|
2013-11-15 07:11:21 +00:00
|
|
|
}
|