mapnik/benchmark/src/test_to_bool.cpp

35 lines
892 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_;
2022-01-26 22:32:21 +00:00
public:
2014-04-26 04:46:40 +00:00
test(mapnik::parameters const& params)
2022-01-26 22:32:21 +00:00
: test_case(params)
, value_("true")
{}
2014-04-26 04:46:40 +00:00
bool validate() const
{
bool result = false;
2022-01-26 22:32:21 +00:00
mapnik::util::string2bool(value_.data(), value_.data() + value_.size(), result);
if (!result)
return result;
mapnik::util::string2bool(value_, result);
2014-04-26 04:46:40 +00:00
return (result == true);
}
bool operator()() const
2014-04-26 04:46:40 +00:00
{
2022-01-26 22:32:21 +00:00
for (std::size_t i = 0; i < iterations_; ++i)
{
2014-04-26 04:46:40 +00:00
bool result = false;
2022-01-26 22:32:21 +00:00
mapnik::util::string2bool(value_, result);
mapnik::util::string2bool(value_.data(), value_.data() + value_.size(), result);
2014-04-26 04:46:40 +00:00
}
return true;
2014-04-26 04:46:40 +00:00
}
};
2022-01-26 22:32:21 +00:00
BENCHMARK(test, "string->bool")