mapnik/benchmark/src/test_to_bool.cpp

31 lines
843 B
C++
Raw Normal View History

2014-04-26 04:46:40 +00:00
#include "bench_framework.hpp"
#include <mapnik/util/conversions.hpp>
class test : public benchmark::test_case
{
std::string value_;
public:
test(mapnik::parameters const& params)
: test_case(params),
value_("true") {}
bool validate() const
{
bool result = false;
mapnik::util::string2bool(value_.data(),value_.data()+value_.size(),result);
if (!result) return result;
mapnik::util::string2bool(value_,result);
return (result == true);
}
bool operator()() const
2014-04-26 04:46:40 +00:00
{
for (std::size_t i=0;i<iterations_;++i) {
bool result = false;
mapnik::util::string2bool(value_,result);
mapnik::util::string2bool(value_.data(),value_.data()+value_.size(),result);
}
return true;
2014-04-26 04:46:40 +00:00
}
};
BENCHMARK(test,"string->bool")