2013-11-15 08:11:21 +01:00
|
|
|
#include "bench_framework.hpp"
|
|
|
|
#include <mapnik/unicode.hpp>
|
2015-12-02 15:32:55 +01:00
|
|
|
#include <mapnik/attribute.hpp>
|
2013-11-15 08:11:21 +01: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 03:25:21 +02:00
|
|
|
expr_("((([mapnik::geometry_type]=2) and ([oneway]=1)) and ([class]='path'))") {}
|
2013-11-15 08:11:21 +01:00
|
|
|
bool validate() const
|
|
|
|
{
|
2014-10-21 07:20:04 +02:00
|
|
|
mapnik::expression_ptr expr = mapnik::parse_expression(expr_);
|
2014-04-30 03:25:21 +02: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 08:11:21 +01:00
|
|
|
}
|
2014-12-12 17:59:45 +01:00
|
|
|
bool operator()() const
|
2013-11-15 08:11:21 +01:00
|
|
|
{
|
|
|
|
for (std::size_t i=0;i<iterations_;++i) {
|
2014-10-21 07:20:04 +02:00
|
|
|
mapnik::expression_ptr expr = mapnik::parse_expression(expr_);
|
2013-11-15 08:11:21 +01:00
|
|
|
}
|
2014-12-12 17:59:45 +01:00
|
|
|
return true;
|
2013-11-15 08:11:21 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
mapnik::parameters params;
|
|
|
|
benchmark::handle_args(argc,argv,params);
|
|
|
|
test test_runner(params);
|
2015-09-14 15:01:32 +02:00
|
|
|
return run(test_runner,"expr parsing");
|
2013-11-15 08:11:21 +01:00
|
|
|
}
|