File: test_png_encoding2.cpp

package info (click to toggle)
mapnik 3.0.12%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 17,084 kB
  • ctags: 18,454
  • sloc: cpp: 142,516; python: 1,416; sh: 769; makefile: 170; xml: 140; lisp: 13
file content (37 lines) | stat: -rw-r--r-- 1,223 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "bench_framework.hpp"
#include "compare_images.hpp"

class test : public benchmark::test_case
{
    std::shared_ptr<image_rgba8> im_;
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);
        }
        im_ = std::make_shared<image_rgba8>(reader->width(),reader->height());
        reader->read(0,0,*im_);
    }
    bool validate() const
    {
        std::string expected("./benchmark/data/multicolor-hextree-expected.png");
        std::string actual("./benchmark/data/multicolor-hextree-actual.png");
        mapnik::save_to_file(*im_,actual, "png8:m=h:z=1");
        return benchmark::compare_images(actual,expected);
    }
    bool operator()() const
    {
        std::string out;
        for (std::size_t i=0;i<iterations_;++i) {
            out.clear();
            out = mapnik::save_to_string(*im_,"png8:m=h:z=1");
        }
        return true;
    }
};

BENCHMARK(test,"encoding multicolor png")