File: test_noop_rendering.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 (53 lines) | stat: -rw-r--r-- 1,636 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "bench_framework.hpp"
#include <mapnik/map.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/load_map.hpp>
#include <mapnik/agg_renderer.hpp>
#include <mapnik/datasource_cache.hpp>
#include <mapnik/font_engine_freetype.hpp>
#include <stdexcept>
#include <mapnik/layer.hpp>
#include <mapnik/memory_datasource.hpp>
#include <mapnik/feature_type_style.hpp>

#include <memory>
    
class test : public benchmark::test_case
{
public:
    test(mapnik::parameters const& params)
     : test_case(params) {}

    bool validate() const
    {
        return true;
    }
    bool operator()() const
    {
        mapnik::Map m(256,256,"+init=epsg:3857");

        mapnik::parameters params;
        params["type"]="memory";
        auto ds = std::make_shared<mapnik::memory_datasource>(params);
        // add whitespace to trigger phony "reprojection"
        mapnik::layer lay("layer",m.srs() + " ");
        lay.set_datasource(ds);
        lay.add_style("style");
        m.add_layer(lay);
        // dummy style to ensure that layer is processed
        m.insert_style("style",mapnik::feature_type_style());
        // dummy bbox, but "valid" because minx and miny are less
        // with an invalid bbox then layer.visible() returns false
        // and the initial rendering setup is not run
        m.zoom_to_box(mapnik::box2d<double>(-1,-1,0,0));
        for (unsigned i=0;i<iterations_;++i)
        {
            mapnik::image_rgba8 im(256,256);
            mapnik::agg_renderer<mapnik::image_rgba8> ren(m,im);
            ren.apply();
        }
        return true;
    }
};

BENCHMARK(test,"rendering with reprojection")