mapnik/benchmark/src/test_expression_parse.cpp

44 lines
1.1 KiB
C++
Raw Normal View History

#include "bench_framework.hpp"
#include <mapnik/unicode.hpp>
2016-08-26 11:09:22 +02:00
#include <mapnik/attribute.hpp>
#include <mapnik/expression.hpp>
#include <mapnik/expression_string.hpp>
class test : public benchmark::test_case
{
std::string expr_;
2022-01-26 23:32:21 +01:00
public:
test(mapnik::parameters const& params)
2022-01-26 23:32:21 +01:00
: test_case(params)
, expr_("((([mapnik::geometry_type]=2) and ([oneway]=1)) and ([class]='path'))")
{}
bool validate() const
{
mapnik::expression_ptr expr = mapnik::parse_expression(expr_);
std::string result = mapnik::to_expression_string(*expr);
bool ret = (result == expr_);
if (!ret)
{
2022-01-26 23:32:21 +01:00
std::clog << result << " != " << expr_ << "\n";
}
return ret;
}
bool operator()() const
{
2022-01-26 23:32:21 +01:00
for (std::size_t i = 0; i < iterations_; ++i)
{
mapnik::expression_ptr expr = mapnik::parse_expression(expr_);
}
return true;
}
};
int main(int argc, char** argv)
{
mapnik::parameters params;
2022-01-26 23:32:21 +01:00
benchmark::handle_args(argc, argv, params);
test test_runner(params);
2022-01-26 23:32:21 +01:00
return run(test_runner, "expr parsing");
}