From 8c8df19cc743f097f1d119d9a0e4423599c93c0c Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Tue, 29 Jan 2013 17:04:35 -0500 Subject: [PATCH] benchmark: add tests for expression grammar parsing - refs #1706 --- benchmark/run.cpp | 69 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/benchmark/run.cpp b/benchmark/run.cpp index 3dc30f044..4bc35d6ad 100644 --- a/benchmark/run.cpp +++ b/benchmark/run.cpp @@ -332,6 +332,65 @@ struct test6 } }; +#include +#include +#include + +struct test7 +{ + unsigned iter_; + unsigned threads_; + std::string expr_; + explicit test7(unsigned iterations, + unsigned threads, + std::string const& expr) : + iter_(iterations), + threads_(threads), + expr_(expr) + {} + + bool validate() + { + mapnik::expression_ptr expr = mapnik::parse_expression(expr_,"utf-8"); + return mapnik::to_expression_string(*expr) == expr_; + } + void operator()() + { + for (int i=0;i + +struct test8 +{ + unsigned iter_; + unsigned threads_; + std::string expr_; + explicit test8(unsigned iterations, + unsigned threads, + std::string const& expr) : + iter_(iterations), + threads_(threads), + expr_(expr) + {} + + bool validate() + { + mapnik::expression_grammar expr_grammar(transcoder("utf-8")); + mapnik::expression_ptr expr = mapnik::parse_expression(expr_,expr_grammar); + return mapnik::to_expression_string(*expr) == expr_; + } + void operator()() + { + mapnik::expression_grammar expr_grammar(transcoder("utf-8")); + for (int i=0;i lonlat coord transformation (literal)"); } + { + test7 runner(10000,100,"([foo]=1)"); + benchmark(runner,"expression parsing with grammer per parse"); + } + + { + test8 runner(10000,100,"([foo]=1)"); + benchmark(runner,"expression parsing by re-using grammar"); + } + std::cout << "...benchmark done\n"; return 0; }