2013-11-15 07:11:21 +00:00
|
|
|
#include "bench_framework.hpp"
|
|
|
|
#include "compare_images.hpp"
|
|
|
|
|
|
|
|
class test : public benchmark::test_case
|
|
|
|
{
|
2015-01-22 02:31:02 +00:00
|
|
|
std::shared_ptr<image_rgba8> im_;
|
2013-11-15 07:11:21 +00:00
|
|
|
public:
|
|
|
|
test(mapnik::parameters const& params)
|
|
|
|
: test_case(params) {
|
|
|
|
std::string filename("./benchmark/data/multicolor.png");
|
|
|
|
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(filename,"png"));
|
|
|
|
if (!reader.get())
|
|
|
|
{
|
|
|
|
throw mapnik::image_reader_exception("Failed to load: " + filename);
|
|
|
|
}
|
2015-01-21 00:30:10 +00:00
|
|
|
im_ = std::make_shared<image_rgba8>(reader->width(),reader->height());
|
|
|
|
reader->read(0,0,*im_);
|
2013-11-15 07:11:21 +00:00
|
|
|
}
|
|
|
|
bool validate() const
|
|
|
|
{
|
|
|
|
std::string expected("./benchmark/data/multicolor-hextree-expected.png");
|
|
|
|
std::string actual("./benchmark/data/multicolor-hextree-actual.png");
|
2015-01-21 00:30:10 +00:00
|
|
|
mapnik::save_to_file(*im_,actual, "png8:m=h:z=1");
|
2013-11-15 07:11:21 +00:00
|
|
|
return benchmark::compare_images(actual,expected);
|
|
|
|
}
|
2014-12-12 16:59:45 +00:00
|
|
|
bool operator()() const
|
2013-11-15 07:11:21 +00:00
|
|
|
{
|
|
|
|
std::string out;
|
|
|
|
for (std::size_t i=0;i<iterations_;++i) {
|
|
|
|
out.clear();
|
2015-01-21 00:30:10 +00:00
|
|
|
out = mapnik::save_to_string(*im_,"png8:m=h:z=1");
|
2013-11-15 07:11:21 +00:00
|
|
|
}
|
|
|
|
}
|
2014-12-12 16:59:45 +00:00
|
|
|
return true;
|
2013-11-15 07:11:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
BENCHMARK(test,"encoding multicolor png")
|