2013-01-09 03:07:11 +00:00
|
|
|
#include <mapnik/graphics.hpp>
|
|
|
|
#include <mapnik/image_data.hpp>
|
|
|
|
#include <mapnik/image_util.hpp>
|
|
|
|
#include <mapnik/image_reader.hpp>
|
2013-01-19 03:00:57 +00:00
|
|
|
#include <mapnik/util/conversions.hpp>
|
2013-01-09 03:07:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
// stl
|
|
|
|
#include <string>
|
|
|
|
#include <iostream>
|
|
|
|
#include <fstream>
|
|
|
|
#include <sstream>
|
2013-01-21 18:31:16 +00:00
|
|
|
#include <cstdio>
|
2013-01-28 01:25:58 +00:00
|
|
|
#include <set>
|
2013-06-03 03:19:33 +00:00
|
|
|
#include <stdexcept>
|
2013-01-09 03:07:11 +00:00
|
|
|
|
|
|
|
// boost
|
2013-02-21 20:36:16 +00:00
|
|
|
#include <boost/version.hpp>
|
2013-09-20 13:13:23 +00:00
|
|
|
#include <memory>
|
2013-01-09 03:07:11 +00:00
|
|
|
#include <boost/make_shared.hpp>
|
2013-01-19 03:00:57 +00:00
|
|
|
#include <boost/bind.hpp>
|
2013-01-09 03:07:11 +00:00
|
|
|
|
|
|
|
#define BOOST_CHRONO_HEADER_ONLY
|
|
|
|
#include <boost/chrono/process_cpu_clocks.hpp>
|
|
|
|
#include <boost/chrono.hpp>
|
|
|
|
#include <boost/thread/thread.hpp>
|
|
|
|
|
|
|
|
using namespace boost::chrono;
|
|
|
|
using namespace mapnik;
|
|
|
|
|
2013-01-28 01:25:58 +00:00
|
|
|
static unsigned test_num = 1;
|
|
|
|
static bool dry_run = false;
|
|
|
|
static std::set<int> test_set;
|
|
|
|
|
2013-01-09 03:07:11 +00:00
|
|
|
typedef process_cpu_clock clock_type;
|
|
|
|
typedef clock_type::duration dur;
|
|
|
|
|
|
|
|
template <typename T>
|
2013-02-28 00:18:28 +00:00
|
|
|
void benchmark(T & test_runner, std::string const& name)
|
2013-01-09 03:07:11 +00:00
|
|
|
{
|
2013-01-29 08:06:44 +00:00
|
|
|
try {
|
|
|
|
bool should_run_test = true;
|
2013-03-14 09:30:41 +00:00
|
|
|
if (!test_set.empty())
|
|
|
|
{
|
2013-01-29 08:06:44 +00:00
|
|
|
should_run_test = test_set.find(test_num) != test_set.end();
|
2013-01-28 01:25:58 +00:00
|
|
|
}
|
2013-03-14 09:30:41 +00:00
|
|
|
if (should_run_test || dry_run)
|
|
|
|
{
|
|
|
|
if (!test_runner.validate())
|
|
|
|
{
|
2013-01-29 08:06:44 +00:00
|
|
|
std::clog << "test did not validate: " << name << "\n";
|
|
|
|
//throw std::runtime_error(std::string("test did not validate: ") + name);
|
|
|
|
}
|
2013-03-14 09:30:41 +00:00
|
|
|
if (dry_run)
|
|
|
|
{
|
2013-02-28 00:18:28 +00:00
|
|
|
std::clog << test_num << ") " << (test_runner.threads_ ? "threaded -> ": "")
|
2013-01-29 08:06:44 +00:00
|
|
|
<< name << "\n";
|
2013-03-14 09:30:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-01-29 08:06:44 +00:00
|
|
|
process_cpu_clock::time_point start;
|
|
|
|
dur elapsed;
|
2013-03-14 09:30:41 +00:00
|
|
|
if (test_runner.threads_ > 0)
|
|
|
|
{
|
2013-01-29 08:06:44 +00:00
|
|
|
boost::thread_group tg;
|
2013-02-28 00:18:28 +00:00
|
|
|
for (unsigned i=0;i<test_runner.threads_;++i)
|
2013-01-29 08:06:44 +00:00
|
|
|
{
|
2013-03-14 09:30:41 +00:00
|
|
|
tg.create_thread(test_runner);
|
|
|
|
//tg.create_thread(boost::bind(&T::operator(),&test_runner));
|
2013-01-29 08:06:44 +00:00
|
|
|
}
|
|
|
|
start = process_cpu_clock::now();
|
|
|
|
tg.join_all();
|
|
|
|
elapsed = process_cpu_clock::now() - start;
|
2013-03-14 09:30:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-01-29 08:06:44 +00:00
|
|
|
start = process_cpu_clock::now();
|
2013-02-28 00:18:28 +00:00
|
|
|
test_runner();
|
2013-01-29 08:06:44 +00:00
|
|
|
elapsed = process_cpu_clock::now() - start;
|
|
|
|
}
|
2013-02-28 00:18:28 +00:00
|
|
|
std::clog << test_num << ") " << (test_runner.threads_ ? "threaded -> ": "")
|
2013-01-29 08:06:44 +00:00
|
|
|
<< name << ": "
|
|
|
|
<< boost::chrono::duration_cast<milliseconds>(elapsed) << "\n";
|
2013-01-28 01:25:58 +00:00
|
|
|
}
|
2013-01-19 03:00:57 +00:00
|
|
|
}
|
2013-03-14 09:30:41 +00:00
|
|
|
}
|
|
|
|
catch (std::exception const& ex)
|
|
|
|
{
|
2013-01-29 08:06:44 +00:00
|
|
|
std::clog << "test runner did not complete: " << ex.what() << "\n";
|
2013-01-19 03:00:57 +00:00
|
|
|
}
|
2013-01-28 01:25:58 +00:00
|
|
|
test_num++;
|
2013-01-09 03:07:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool compare_images(std::string const& src_fn,std::string const& dest_fn)
|
|
|
|
{
|
2013-04-19 08:50:50 +00:00
|
|
|
std::unique_ptr<mapnik::image_reader> reader1(mapnik::get_image_reader(dest_fn,"png"));
|
2013-01-09 03:07:11 +00:00
|
|
|
if (!reader1.get())
|
|
|
|
{
|
|
|
|
throw mapnik::image_reader_exception("Failed to load: " + dest_fn);
|
|
|
|
}
|
2013-09-20 13:00:11 +00:00
|
|
|
std::shared_ptr<image_32> image_ptr1 = std::make_shared<image_32>(reader1->width(),reader1->height());
|
2013-01-09 03:07:11 +00:00
|
|
|
reader1->read(0,0,image_ptr1->data());
|
|
|
|
|
2013-04-19 08:50:50 +00:00
|
|
|
std::unique_ptr<mapnik::image_reader> reader2(mapnik::get_image_reader(src_fn,"png"));
|
2013-01-09 03:07:11 +00:00
|
|
|
if (!reader2.get())
|
|
|
|
{
|
|
|
|
throw mapnik::image_reader_exception("Failed to load: " + src_fn);
|
|
|
|
}
|
2013-09-20 13:00:11 +00:00
|
|
|
std::shared_ptr<image_32> image_ptr2 = std::make_shared<image_32>(reader2->width(),reader2->height());
|
2013-01-09 03:07:11 +00:00
|
|
|
reader2->read(0,0,image_ptr2->data());
|
2013-01-21 18:31:16 +00:00
|
|
|
|
2013-01-09 03:07:11 +00:00
|
|
|
image_data_32 const& dest = image_ptr1->data();
|
|
|
|
image_data_32 const& src = image_ptr2->data();
|
|
|
|
|
|
|
|
unsigned int width = src.width();
|
|
|
|
unsigned int height = src.height();
|
|
|
|
if ((width != dest.width()) || height != dest.height()) return false;
|
|
|
|
for (unsigned int y = 0; y < height; ++y)
|
|
|
|
{
|
|
|
|
const unsigned int* row_from = src.getRow(y);
|
|
|
|
const unsigned int* row_to = dest.getRow(y);
|
|
|
|
for (unsigned int x = 0; x < width; ++x)
|
|
|
|
{
|
|
|
|
if (row_from[x] != row_to[x]) return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct test1
|
|
|
|
{
|
|
|
|
unsigned iter_;
|
2013-01-19 03:00:57 +00:00
|
|
|
unsigned threads_;
|
|
|
|
explicit test1(unsigned iterations, unsigned threads=0) :
|
|
|
|
iter_(iterations),
|
|
|
|
threads_(threads)
|
|
|
|
{}
|
2013-01-09 03:07:11 +00:00
|
|
|
|
|
|
|
bool validate()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2013-01-21 18:31:16 +00:00
|
|
|
|
2013-01-19 03:00:57 +00:00
|
|
|
void operator()()
|
2013-01-09 03:07:11 +00:00
|
|
|
{
|
|
|
|
mapnik::image_data_32 im(256,256);
|
|
|
|
std::string out;
|
2013-01-21 22:12:27 +00:00
|
|
|
for (unsigned i=0;i<iter_;++i) {
|
2013-01-09 03:07:11 +00:00
|
|
|
out.clear();
|
|
|
|
out = mapnik::save_to_string(im,"png");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct test2
|
|
|
|
{
|
|
|
|
unsigned iter_;
|
2013-01-19 03:00:57 +00:00
|
|
|
unsigned threads_;
|
2013-09-20 13:00:11 +00:00
|
|
|
std::shared_ptr<image_32> im_;
|
2013-01-19 03:00:57 +00:00
|
|
|
explicit test2(unsigned iterations, unsigned threads=0) :
|
2013-01-09 03:07:11 +00:00
|
|
|
iter_(iterations),
|
2013-01-19 03:00:57 +00:00
|
|
|
threads_(threads),
|
2013-01-09 03:07:11 +00:00
|
|
|
im_()
|
|
|
|
{
|
|
|
|
std::string filename("./benchmark/data/multicolor.png");
|
2013-04-19 08:50:50 +00:00
|
|
|
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(filename,"png"));
|
2013-01-09 03:07:11 +00:00
|
|
|
if (!reader.get())
|
|
|
|
{
|
|
|
|
throw mapnik::image_reader_exception("Failed to load: " + filename);
|
|
|
|
}
|
2013-09-20 13:00:11 +00:00
|
|
|
im_ = std::make_shared<image_32>(reader->width(),reader->height());
|
2013-01-09 03:07:11 +00:00
|
|
|
reader->read(0,0,im_->data());
|
|
|
|
}
|
2013-01-21 18:31:16 +00:00
|
|
|
|
2013-01-09 03:07:11 +00:00
|
|
|
bool validate()
|
|
|
|
{
|
|
|
|
std::string expected("./benchmark/data/multicolor-hextree-expected.png");
|
|
|
|
std::string actual("./benchmark/data/multicolor-hextree-actual.png");
|
|
|
|
mapnik::save_to_file(im_->data(),actual, "png8:m=h");
|
|
|
|
return compare_images(actual,expected);
|
|
|
|
}
|
2013-01-21 18:31:16 +00:00
|
|
|
|
2013-01-19 03:00:57 +00:00
|
|
|
void operator()()
|
2013-01-09 03:07:11 +00:00
|
|
|
{
|
|
|
|
std::string out;
|
2013-01-21 22:12:27 +00:00
|
|
|
for (unsigned i=0;i<iter_;++i) {
|
2013-01-09 03:07:11 +00:00
|
|
|
out.clear();
|
|
|
|
out = mapnik::save_to_string(im_->data(),"png8:m=h");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-01-19 03:00:57 +00:00
|
|
|
struct test3
|
|
|
|
{
|
|
|
|
unsigned iter_;
|
|
|
|
unsigned threads_;
|
|
|
|
double val_;
|
|
|
|
explicit test3(unsigned iterations, unsigned threads=0) :
|
|
|
|
iter_(iterations),
|
|
|
|
threads_(threads),
|
2013-01-21 18:31:16 +00:00
|
|
|
val_(-0.123) {}
|
2013-01-19 03:00:57 +00:00
|
|
|
bool validate()
|
|
|
|
{
|
|
|
|
std::ostringstream s;
|
|
|
|
s << val_;
|
2013-01-21 18:31:16 +00:00
|
|
|
return (s.str() == "-0.123");
|
2013-01-19 03:00:57 +00:00
|
|
|
}
|
|
|
|
void operator()()
|
|
|
|
{
|
|
|
|
std::string out;
|
2013-01-21 22:12:27 +00:00
|
|
|
for (unsigned i=0;i<iter_;++i) {
|
2013-01-19 03:00:57 +00:00
|
|
|
std::ostringstream s;
|
|
|
|
s << val_;
|
|
|
|
out = s.str();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct test4
|
|
|
|
{
|
|
|
|
unsigned iter_;
|
|
|
|
unsigned threads_;
|
|
|
|
double val_;
|
|
|
|
explicit test4(unsigned iterations, unsigned threads=0) :
|
|
|
|
iter_(iterations),
|
|
|
|
threads_(threads),
|
2013-01-21 18:31:16 +00:00
|
|
|
val_(-0.123) {}
|
2013-01-19 03:00:57 +00:00
|
|
|
|
|
|
|
bool validate()
|
|
|
|
{
|
|
|
|
std::string s;
|
2013-01-21 18:31:16 +00:00
|
|
|
mapnik::util::to_string(s,val_);
|
|
|
|
return (s == "-0.123");
|
2013-01-19 03:00:57 +00:00
|
|
|
}
|
|
|
|
void operator()()
|
|
|
|
{
|
2013-01-21 18:31:16 +00:00
|
|
|
std::string out;
|
2013-01-21 22:12:27 +00:00
|
|
|
for (unsigned i=0;i<iter_;++i) {
|
2013-01-21 18:31:16 +00:00
|
|
|
out.clear();
|
2013-01-19 03:00:57 +00:00
|
|
|
mapnik::util::to_string(out,val_);
|
2013-01-21 18:31:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct test5
|
|
|
|
{
|
|
|
|
unsigned iter_;
|
|
|
|
unsigned threads_;
|
|
|
|
double val_;
|
|
|
|
explicit test5(unsigned iterations, unsigned threads=0) :
|
|
|
|
iter_(iterations),
|
|
|
|
threads_(threads),
|
|
|
|
val_(-0.123) {}
|
|
|
|
|
|
|
|
bool validate()
|
|
|
|
{
|
|
|
|
std::string s;
|
|
|
|
to_string_impl(s,val_);
|
|
|
|
return (s == "-0.123");
|
|
|
|
}
|
2013-01-21 22:12:27 +00:00
|
|
|
bool to_string_impl(std::string &s , double val)
|
2013-01-21 18:31:16 +00:00
|
|
|
{
|
|
|
|
s.resize(s.capacity());
|
|
|
|
while (true)
|
|
|
|
{
|
2013-07-23 19:51:22 +00:00
|
|
|
size_t n2 = static_cast<size_t>(snprintf(&s[0], s.size()+1, "%g", val));
|
2013-01-21 18:31:16 +00:00
|
|
|
if (n2 <= s.size())
|
|
|
|
{
|
|
|
|
s.resize(n2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
s.resize(n2);
|
|
|
|
}
|
2013-01-21 22:12:27 +00:00
|
|
|
return true;
|
2013-01-21 18:31:16 +00:00
|
|
|
}
|
|
|
|
void operator()()
|
|
|
|
{
|
|
|
|
std::string out;
|
2013-01-21 22:12:27 +00:00
|
|
|
for (unsigned i=0;i<iter_;++i)
|
2013-01-21 18:31:16 +00:00
|
|
|
{
|
|
|
|
out.clear();
|
|
|
|
to_string_impl(out , val_);
|
2013-01-19 03:00:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-01-09 03:07:11 +00:00
|
|
|
|
2013-01-28 01:26:32 +00:00
|
|
|
#include <mapnik/box2d.hpp>
|
|
|
|
#include <mapnik/projection.hpp>
|
|
|
|
#include <mapnik/proj_transform.hpp>
|
|
|
|
|
|
|
|
struct test6
|
|
|
|
{
|
|
|
|
unsigned iter_;
|
|
|
|
unsigned threads_;
|
|
|
|
std::string src_;
|
|
|
|
std::string dest_;
|
|
|
|
mapnik::box2d<double> from_;
|
|
|
|
mapnik::box2d<double> to_;
|
2013-01-28 06:47:32 +00:00
|
|
|
bool defer_proj4_init_;
|
2013-01-28 01:26:32 +00:00
|
|
|
explicit test6(unsigned iterations,
|
|
|
|
unsigned threads,
|
|
|
|
std::string const& src,
|
|
|
|
std::string const& dest,
|
|
|
|
mapnik::box2d<double> from,
|
2013-01-28 06:47:32 +00:00
|
|
|
mapnik::box2d<double> to,
|
|
|
|
bool defer_proj) :
|
2013-01-28 01:26:32 +00:00
|
|
|
iter_(iterations),
|
|
|
|
threads_(threads),
|
|
|
|
src_(src),
|
|
|
|
dest_(dest),
|
|
|
|
from_(from),
|
2013-01-28 06:47:32 +00:00
|
|
|
to_(to),
|
|
|
|
defer_proj4_init_(defer_proj) {}
|
2013-01-28 01:26:32 +00:00
|
|
|
|
|
|
|
bool validate()
|
|
|
|
{
|
2013-01-28 06:47:32 +00:00
|
|
|
mapnik::projection src(src_,defer_proj4_init_);
|
|
|
|
mapnik::projection dest(dest_,defer_proj4_init_);
|
2013-01-28 01:26:32 +00:00
|
|
|
mapnik::proj_transform tr(src,dest);
|
|
|
|
mapnik::box2d<double> bbox = from_;
|
|
|
|
if (!tr.forward(bbox)) return false;
|
|
|
|
return ((std::fabs(bbox.minx() - to_.minx()) < .5) &&
|
|
|
|
(std::fabs(bbox.maxx() - to_.maxx()) < .5) &&
|
|
|
|
(std::fabs(bbox.miny() - to_.miny()) < .5) &&
|
|
|
|
(std::fabs(bbox.maxy() - to_.maxy()) < .5)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
void operator()()
|
|
|
|
{
|
|
|
|
unsigned count=0;
|
2013-01-29 08:30:22 +00:00
|
|
|
for (int i=-180;i<180;++i)
|
2013-01-28 01:26:32 +00:00
|
|
|
{
|
|
|
|
for (int j=-85;j<85;++j)
|
|
|
|
{
|
2013-01-28 06:47:32 +00:00
|
|
|
mapnik::projection src(src_,defer_proj4_init_);
|
|
|
|
mapnik::projection dest(dest_,defer_proj4_init_);
|
|
|
|
mapnik::proj_transform tr(src,dest);
|
|
|
|
mapnik::box2d<double> box(i,j,i,j);
|
|
|
|
if (!tr.forward(box)) throw std::runtime_error("could not transform coords");
|
|
|
|
++count;
|
2013-01-28 01:26:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-01-29 22:04:35 +00:00
|
|
|
#include <mapnik/unicode.hpp>
|
|
|
|
#include <mapnik/expression.hpp>
|
|
|
|
#include <mapnik/expression_string.hpp>
|
|
|
|
|
|
|
|
struct test7
|
|
|
|
{
|
|
|
|
unsigned iter_;
|
|
|
|
unsigned threads_;
|
|
|
|
std::string expr_;
|
|
|
|
explicit test7(unsigned iterations,
|
|
|
|
unsigned threads,
|
|
|
|
std::string const& expr) :
|
|
|
|
iter_(iterations),
|
|
|
|
threads_(threads),
|
|
|
|
expr_(expr)
|
|
|
|
{}
|
|
|
|
|
|
|
|
bool validate()
|
|
|
|
{
|
|
|
|
mapnik::expression_ptr expr = mapnik::parse_expression(expr_,"utf-8");
|
|
|
|
return mapnik::to_expression_string(*expr) == expr_;
|
|
|
|
}
|
|
|
|
void operator()()
|
|
|
|
{
|
2013-02-14 00:38:56 +00:00
|
|
|
for (unsigned i=0;i<iter_;++i) {
|
2013-01-29 22:04:35 +00:00
|
|
|
mapnik::expression_ptr expr = mapnik::parse_expression(expr_,"utf-8");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#include <mapnik/expression_grammar.hpp>
|
|
|
|
|
|
|
|
struct test8
|
|
|
|
{
|
|
|
|
unsigned iter_;
|
|
|
|
unsigned threads_;
|
|
|
|
std::string expr_;
|
|
|
|
explicit test8(unsigned iterations,
|
|
|
|
unsigned threads,
|
|
|
|
std::string const& expr) :
|
|
|
|
iter_(iterations),
|
|
|
|
threads_(threads),
|
|
|
|
expr_(expr)
|
|
|
|
{}
|
|
|
|
|
|
|
|
bool validate()
|
|
|
|
{
|
2013-03-19 21:09:01 +00:00
|
|
|
transcoder tr("utf-8");
|
|
|
|
mapnik::expression_grammar<std::string::const_iterator> expr_grammar(tr);
|
|
|
|
mapnik::expression_ptr expr = mapnik::parse_expression(expr_,expr_grammar);
|
|
|
|
return mapnik::to_expression_string(*expr) == expr_;
|
2013-01-29 22:04:35 +00:00
|
|
|
}
|
|
|
|
void operator()()
|
|
|
|
{
|
2013-03-19 21:09:01 +00:00
|
|
|
transcoder tr("utf-8");
|
|
|
|
mapnik::expression_grammar<std::string::const_iterator> expr_grammar(tr);
|
2013-02-14 00:38:56 +00:00
|
|
|
for (unsigned i=0;i<iter_;++i) {
|
2013-01-29 22:04:35 +00:00
|
|
|
mapnik::expression_ptr expr = mapnik::parse_expression(expr_,expr_grammar);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2013-01-28 01:26:32 +00:00
|
|
|
|
2013-10-02 22:14:52 +00:00
|
|
|
#include "agg_conv_clip_polygon.h"
|
2013-02-28 00:18:28 +00:00
|
|
|
#include <mapnik/wkt/wkt_factory.hpp>
|
2013-10-02 22:14:52 +00:00
|
|
|
#include <mapnik/util/geometry_to_wkt.hpp>
|
|
|
|
#include <mapnik/geometry.hpp>
|
|
|
|
|
|
|
|
#include "agg_conv_clip_polygon.h"
|
|
|
|
|
|
|
|
struct test11a
|
|
|
|
{
|
|
|
|
unsigned iter_;
|
|
|
|
unsigned threads_;
|
|
|
|
std::string wkt_in_;
|
|
|
|
mapnik::box2d<double> extent_;
|
|
|
|
typedef agg::conv_clip_polygon<mapnik::geometry_type> conv_clip;
|
|
|
|
test11a(unsigned iterations,
|
|
|
|
unsigned threads,
|
|
|
|
std::string wkt_in,
|
|
|
|
mapnik::box2d<double> const& extent)
|
|
|
|
: iter_(iterations),
|
|
|
|
threads_(threads),
|
|
|
|
wkt_in_(wkt_in),
|
|
|
|
extent_(extent) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool validate()
|
|
|
|
{
|
|
|
|
std::string expected_wkt("Polygon((181 286.666667,233 454,315 340,421 446,463 324,559 466,631 321.320755,631 234.386861,528 178,394 229,329 138,212 134,183 228,200 264,181 238.244444),(313 190,440 256,470 248,510 305,533 237,613 263,553 397,455 262,405 378,343 287,249 334,229 191,313 190,313 190))");
|
|
|
|
boost::ptr_vector<geometry_type> paths;
|
|
|
|
if (!mapnik::from_wkt(wkt_in_, paths))
|
|
|
|
{
|
|
|
|
throw std::runtime_error("Failed to parse WKT");
|
|
|
|
}
|
2013-10-03 01:25:24 +00:00
|
|
|
for (geometry_type & geom : paths)
|
2013-10-02 22:14:52 +00:00
|
|
|
{
|
|
|
|
conv_clip clipped(geom);
|
|
|
|
clipped.clip_box(
|
|
|
|
extent_.minx(),
|
|
|
|
extent_.miny(),
|
|
|
|
extent_.maxx(),
|
|
|
|
extent_.maxy());
|
|
|
|
unsigned cmd;
|
|
|
|
double x,y;
|
2013-10-03 02:37:07 +00:00
|
|
|
mapnik::geometry_type geom2(mapnik::geometry_type::types::Polygon);
|
2013-10-02 22:14:52 +00:00
|
|
|
while ((cmd = clipped.vertex(&x, &y)) != SEG_END) {
|
|
|
|
geom2.push_vertex(x,y,(mapnik::CommandType)cmd);
|
|
|
|
}
|
|
|
|
std::string wkt;
|
|
|
|
bool result = mapnik::util::to_wkt(wkt,geom2);
|
|
|
|
if (result) {
|
|
|
|
return (wkt == expected_wkt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
void operator()()
|
|
|
|
{
|
|
|
|
boost::ptr_vector<geometry_type> paths;
|
|
|
|
if (!mapnik::from_wkt(wkt_in_, paths))
|
|
|
|
{
|
|
|
|
throw std::runtime_error("Failed to parse WKT");
|
|
|
|
}
|
|
|
|
for (unsigned i=0;i<iter_;++i)
|
|
|
|
{
|
2013-10-03 01:25:24 +00:00
|
|
|
for (geometry_type & geom : paths)
|
2013-10-02 22:14:52 +00:00
|
|
|
{
|
|
|
|
conv_clip clipped(geom);
|
|
|
|
clipped.clip_box(
|
|
|
|
extent_.minx(),
|
|
|
|
extent_.miny(),
|
|
|
|
extent_.maxx(),
|
|
|
|
extent_.maxy());
|
|
|
|
unsigned cmd;
|
|
|
|
double x,y;
|
|
|
|
while ((cmd = clipped.vertex(&x, &y)) != SEG_END) {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-02-28 00:18:28 +00:00
|
|
|
#include "agg_conv_clipper.h"
|
|
|
|
#include "agg_path_storage.h"
|
|
|
|
|
|
|
|
struct test11
|
|
|
|
{
|
|
|
|
unsigned iter_;
|
|
|
|
unsigned threads_;
|
2013-03-14 09:30:41 +00:00
|
|
|
std::string wkt_in_;
|
2013-02-28 00:18:28 +00:00
|
|
|
mapnik::box2d<double> extent_;
|
|
|
|
typedef agg::conv_clipper<mapnik::geometry_type, agg::path_storage> poly_clipper;
|
2013-03-14 09:30:41 +00:00
|
|
|
test11(unsigned iterations,
|
|
|
|
unsigned threads,
|
|
|
|
std::string wkt_in,
|
|
|
|
mapnik::box2d<double> const& extent)
|
|
|
|
: iter_(iterations),
|
|
|
|
threads_(threads),
|
|
|
|
wkt_in_(wkt_in),
|
|
|
|
extent_(extent) {
|
|
|
|
|
|
|
|
}
|
2013-02-28 00:18:28 +00:00
|
|
|
|
|
|
|
bool validate()
|
|
|
|
{
|
2013-10-02 22:14:52 +00:00
|
|
|
std::string expected_wkt("Polygon((212 134,329 138,394 229,528 178,631 234.4,631 321.3,559 466,463 324,421 446,315 340,233 454,181 286.7,181 238.2,200 264,183 228),(313 190,229 191,249 334,343 287,405 378,455 262,553 397,613 263,533 237,510 305,470 248,440 256))");
|
|
|
|
boost::ptr_vector<geometry_type> paths;
|
|
|
|
if (!mapnik::from_wkt(wkt_in_, paths))
|
|
|
|
{
|
|
|
|
throw std::runtime_error("Failed to parse WKT");
|
|
|
|
}
|
|
|
|
agg::path_storage ps;
|
|
|
|
ps.move_to(extent_.minx(), extent_.miny());
|
|
|
|
ps.line_to(extent_.minx(), extent_.maxy());
|
|
|
|
ps.line_to(extent_.maxx(), extent_.maxy());
|
|
|
|
ps.line_to(extent_.maxx(), extent_.miny());
|
|
|
|
ps.close_polygon();
|
2013-10-03 01:25:24 +00:00
|
|
|
for (geometry_type & geom : paths)
|
2013-10-02 22:14:52 +00:00
|
|
|
{
|
|
|
|
poly_clipper clipped(geom,ps,
|
|
|
|
agg::clipper_and,
|
|
|
|
agg::clipper_non_zero,
|
|
|
|
agg::clipper_non_zero,
|
|
|
|
1);
|
|
|
|
clipped.rewind(0);
|
|
|
|
unsigned cmd;
|
|
|
|
double x,y;
|
2013-10-03 02:37:07 +00:00
|
|
|
mapnik::geometry_type geom2(mapnik::geometry_type::types::Polygon);
|
2013-10-02 22:14:52 +00:00
|
|
|
while ((cmd = clipped.vertex(&x, &y)) != SEG_END) {
|
|
|
|
geom2.push_vertex(x,y,(mapnik::CommandType)cmd);
|
|
|
|
}
|
|
|
|
std::string wkt;
|
|
|
|
bool result = mapnik::util::to_wkt(wkt,geom2);
|
|
|
|
if (result) {
|
|
|
|
return (wkt == expected_wkt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2013-02-28 00:18:28 +00:00
|
|
|
}
|
|
|
|
void operator()()
|
|
|
|
{
|
2013-03-14 09:30:41 +00:00
|
|
|
boost::ptr_vector<geometry_type> paths;
|
|
|
|
if (!mapnik::from_wkt(wkt_in_, paths))
|
|
|
|
{
|
|
|
|
throw std::runtime_error("Failed to parse WKT");
|
|
|
|
}
|
2013-02-28 00:18:28 +00:00
|
|
|
agg::path_storage ps;
|
|
|
|
ps.move_to(extent_.minx(), extent_.miny());
|
|
|
|
ps.line_to(extent_.minx(), extent_.maxy());
|
|
|
|
ps.line_to(extent_.maxx(), extent_.maxy());
|
|
|
|
ps.line_to(extent_.maxx(), extent_.miny());
|
|
|
|
ps.close_polygon();
|
2013-04-24 15:40:35 +00:00
|
|
|
for (unsigned i=0;i<iter_;++i)
|
|
|
|
{
|
|
|
|
for (geometry_type & geom : paths)
|
2013-02-28 00:18:28 +00:00
|
|
|
{
|
|
|
|
poly_clipper clipped(geom,ps,
|
2013-09-17 10:59:38 +00:00
|
|
|
agg::clipper_and,
|
|
|
|
agg::clipper_non_zero,
|
|
|
|
agg::clipper_non_zero,
|
|
|
|
1);
|
2013-02-28 00:18:28 +00:00
|
|
|
clipped.rewind(0);
|
|
|
|
unsigned cmd;
|
|
|
|
double x,y;
|
2013-09-16 14:02:58 +00:00
|
|
|
while ((cmd = clipped.vertex(&x, &y)) != SEG_END) {}
|
2013-02-28 00:18:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-03-14 09:30:41 +00:00
|
|
|
#include <mapnik/polygon_clipper.hpp>
|
|
|
|
|
|
|
|
struct test12
|
|
|
|
{
|
|
|
|
unsigned iter_;
|
|
|
|
unsigned threads_;
|
|
|
|
std::string wkt_in_;
|
|
|
|
mapnik::box2d<double> extent_;
|
|
|
|
typedef mapnik::polygon_clipper<mapnik::geometry_type> poly_clipper;
|
|
|
|
test12(unsigned iterations,
|
|
|
|
unsigned threads,
|
|
|
|
std::string wkt_in,
|
|
|
|
mapnik::box2d<double> const& extent)
|
|
|
|
: iter_(iterations),
|
|
|
|
threads_(threads),
|
|
|
|
wkt_in_(wkt_in),
|
|
|
|
extent_(extent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool validate()
|
|
|
|
{
|
2013-10-02 22:14:52 +00:00
|
|
|
std::string expected_wkt("Polygon((181 286.666667,233 454,315 340,421 446,463 324,559 466,631 321.320755,631 234.386861,528 178,394 229,329 138,212 134,183 228,200 264,181 238.244444,181 286.666667),(313 190,440 256,470 248,510 305,533 237,613 263,553 397,455 262,405 378,343 287,249 334,229 191,313 190))");
|
|
|
|
boost::ptr_vector<geometry_type> paths;
|
|
|
|
if (!mapnik::from_wkt(wkt_in_, paths))
|
|
|
|
{
|
|
|
|
throw std::runtime_error("Failed to parse WKT");
|
|
|
|
}
|
2013-10-03 01:25:24 +00:00
|
|
|
for ( geometry_type & geom : paths)
|
2013-10-02 22:14:52 +00:00
|
|
|
{
|
|
|
|
poly_clipper clipped(extent_, geom);
|
|
|
|
unsigned cmd;
|
|
|
|
double x,y;
|
2013-10-03 02:37:07 +00:00
|
|
|
mapnik::geometry_type geom2(mapnik::geometry_type::types::Polygon);
|
2013-10-02 22:14:52 +00:00
|
|
|
while ((cmd = clipped.vertex(&x, &y)) != SEG_END) {
|
|
|
|
geom2.push_vertex(x,y,(mapnik::CommandType)cmd);
|
|
|
|
}
|
|
|
|
std::string wkt;
|
|
|
|
bool result = mapnik::util::to_wkt(wkt,geom2);
|
|
|
|
if (result) {
|
|
|
|
return (wkt == expected_wkt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2013-03-14 09:30:41 +00:00
|
|
|
}
|
|
|
|
void operator()()
|
|
|
|
{
|
|
|
|
boost::ptr_vector<geometry_type> paths;
|
|
|
|
if (!mapnik::from_wkt(wkt_in_, paths))
|
|
|
|
{
|
|
|
|
throw std::runtime_error("Failed to parse WKT");
|
|
|
|
}
|
|
|
|
for (unsigned i=0;i<iter_;++i)
|
|
|
|
{
|
2013-04-24 15:40:35 +00:00
|
|
|
for ( geometry_type & geom : paths)
|
2013-03-14 09:30:41 +00:00
|
|
|
{
|
|
|
|
poly_clipper clipped(extent_, geom);
|
|
|
|
unsigned cmd;
|
|
|
|
double x,y;
|
2013-09-16 14:02:58 +00:00
|
|
|
while ((cmd = clipped.vertex(&x, &y)) != SEG_END) {}
|
2013-03-14 09:30:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-04-03 12:52:54 +00:00
|
|
|
#include <mapnik/font_engine_freetype.hpp>
|
2013-04-03 13:17:18 +00:00
|
|
|
#include <boost/format.hpp>
|
2013-04-03 12:52:54 +00:00
|
|
|
struct test13
|
|
|
|
{
|
|
|
|
unsigned iter_;
|
|
|
|
unsigned threads_;
|
|
|
|
|
|
|
|
test13(unsigned iterations,
|
|
|
|
unsigned threads)
|
|
|
|
: iter_(iterations),
|
|
|
|
threads_(threads)
|
2013-04-03 13:17:18 +00:00
|
|
|
{}
|
2013-04-03 12:52:54 +00:00
|
|
|
|
|
|
|
bool validate()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void operator()()
|
|
|
|
{
|
|
|
|
mapnik::freetype_engine engine;
|
|
|
|
unsigned long count = 0;
|
|
|
|
for (unsigned i=0;i<iter_;++i)
|
|
|
|
{
|
2013-04-24 15:40:35 +00:00
|
|
|
for ( std::string const& name : mapnik::freetype_engine::face_names())
|
2013-04-03 12:52:54 +00:00
|
|
|
{
|
|
|
|
mapnik::face_ptr f = engine.create_face(name);
|
|
|
|
if (f) ++count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-10-02 23:09:32 +00:00
|
|
|
#include <mapnik/map.hpp>
|
|
|
|
#include <mapnik/load_map.hpp>
|
|
|
|
#include <mapnik/agg_renderer.hpp>
|
|
|
|
#include <mapnik/datasource_cache.hpp>
|
|
|
|
|
|
|
|
struct test14
|
|
|
|
{
|
|
|
|
unsigned iter_;
|
|
|
|
unsigned threads_;
|
|
|
|
std::string xml_;
|
|
|
|
mapnik::box2d<double> extent_;
|
|
|
|
test14(unsigned iterations,
|
|
|
|
unsigned threads,
|
|
|
|
std::string const& xml,
|
|
|
|
mapnik::box2d<double> const& extent)
|
|
|
|
: iter_(iterations),
|
|
|
|
threads_(threads),
|
|
|
|
xml_(xml),
|
|
|
|
extent_(extent)
|
|
|
|
{}
|
|
|
|
|
|
|
|
bool validate()
|
|
|
|
{
|
|
|
|
mapnik::Map m(256,256);
|
|
|
|
mapnik::load_map(m,xml_);
|
|
|
|
m.zoom_to_box(extent_);
|
|
|
|
mapnik::image_32 im(m.width(),m.height());
|
|
|
|
mapnik::agg_renderer<mapnik::image_32> ren(m,im);
|
|
|
|
ren.apply();
|
|
|
|
//mapnik::save_to_file(im,"test.png");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void operator()()
|
|
|
|
{
|
|
|
|
mapnik::Map m(256,256);
|
|
|
|
mapnik::load_map(m,xml_);
|
|
|
|
m.zoom_to_box(extent_);
|
|
|
|
for (unsigned i=0;i<iter_;++i)
|
|
|
|
{
|
|
|
|
mapnik::image_32 im(m.width(),m.height());
|
|
|
|
mapnik::agg_renderer<mapnik::image_32> ren(m,im);
|
|
|
|
ren.apply();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-01-28 01:25:58 +00:00
|
|
|
int main( int argc, char** argv)
|
2013-01-09 03:07:11 +00:00
|
|
|
{
|
2013-01-28 01:25:58 +00:00
|
|
|
if (argc > 0) {
|
|
|
|
for (int i=0;i<argc;++i) {
|
|
|
|
std::string opt(argv[i]);
|
|
|
|
if (opt == "-d" || opt == "--dry-run") {
|
|
|
|
dry_run = true;
|
|
|
|
} else if (opt[0] != '-') {
|
|
|
|
int arg;
|
|
|
|
if (mapnik::util::string2int(opt,arg)) {
|
|
|
|
test_set.insert(arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-10-02 23:09:32 +00:00
|
|
|
mapnik::datasource_cache::instance().register_datasources("./plugins/input/");
|
2013-01-09 03:07:11 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
std::cout << "starting benchmark…\n";
|
2013-01-28 01:25:58 +00:00
|
|
|
|
2013-01-09 03:07:11 +00:00
|
|
|
{
|
2013-01-21 22:12:27 +00:00
|
|
|
test1 runner(100);
|
|
|
|
benchmark(runner,"encoding blank image as png");
|
2013-01-09 03:07:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2013-01-21 22:12:27 +00:00
|
|
|
test2 runner(100);
|
|
|
|
benchmark(runner,"encoding multicolor image as png8:m=h");
|
2013-01-09 03:07:11 +00:00
|
|
|
}
|
|
|
|
|
2013-01-19 03:00:57 +00:00
|
|
|
{
|
2013-01-21 22:12:27 +00:00
|
|
|
test1 runner(10,10);
|
|
|
|
benchmark(runner,"encoding blank image as png");
|
2013-01-19 03:00:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2013-01-21 22:12:27 +00:00
|
|
|
test2 runner(10,10);
|
|
|
|
benchmark(runner,"encoding multicolor image as png8:m=h");
|
2013-01-19 03:00:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2013-01-21 22:12:27 +00:00
|
|
|
test3 runner(1000000);
|
|
|
|
benchmark(runner,"double to string conversion with std::ostringstream");
|
2013-01-19 03:00:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2013-01-21 22:12:27 +00:00
|
|
|
test4 runner(1000000);
|
|
|
|
benchmark(runner,"double to string conversion with mapnik::util_to_string");
|
2013-01-19 03:00:57 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 18:31:16 +00:00
|
|
|
{
|
|
|
|
test5 runner(1000000);
|
|
|
|
benchmark(runner,"double to string conversion with snprintf");
|
|
|
|
}
|
|
|
|
|
2013-01-19 03:00:57 +00:00
|
|
|
{
|
2013-01-21 22:12:27 +00:00
|
|
|
test3 runner(1000000,10);
|
|
|
|
benchmark(runner,"double to string conversion with std::ostringstream");
|
2013-01-19 03:00:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2013-01-21 22:12:27 +00:00
|
|
|
test4 runner(1000000,10);
|
|
|
|
benchmark(runner,"double to string conversion with mapnik::util_to_string");
|
2013-01-19 03:00:57 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 18:31:16 +00:00
|
|
|
{
|
2013-01-21 22:12:27 +00:00
|
|
|
test5 runner(1000000,10);
|
|
|
|
benchmark(runner,"double to string conversion with snprintf");
|
2013-01-21 18:31:16 +00:00
|
|
|
}
|
|
|
|
|
2013-01-28 01:26:32 +00:00
|
|
|
mapnik::box2d<double> from(-180,-80,180,80);
|
|
|
|
mapnik::box2d<double> to(-20037508.3427892476,-15538711.0963092316,20037508.3427892476,15538711.0963092316);
|
2013-01-28 06:47:32 +00:00
|
|
|
|
2013-01-28 01:26:32 +00:00
|
|
|
{
|
|
|
|
// echo -180 -60 | cs2cs -f "%.10f" +init=epsg:4326 +to +init=epsg:3857
|
|
|
|
test6 runner(100000000,100,
|
|
|
|
"+init=epsg:4326",
|
|
|
|
"+init=epsg:3857",
|
2013-01-29 08:06:44 +00:00
|
|
|
from,to,true);
|
2013-01-28 01:26:32 +00:00
|
|
|
benchmark(runner,"lonlat -> merc coord transformation (epsg)");
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
test6 runner(100000000,100,
|
|
|
|
"+init=epsg:3857",
|
|
|
|
"+init=epsg:4326",
|
2013-01-29 08:06:44 +00:00
|
|
|
to,from,true);
|
2013-01-28 01:26:32 +00:00
|
|
|
benchmark(runner,"merc -> lonlat coord transformation (epsg)");
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
test6 runner(100000000,100,
|
|
|
|
"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs",
|
|
|
|
"+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over",
|
2013-01-29 08:06:44 +00:00
|
|
|
from,to,true);
|
2013-01-28 01:26:32 +00:00
|
|
|
benchmark(runner,"lonlat -> merc coord transformation (literal)");
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
test6 runner(100000000,100,
|
|
|
|
"+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over",
|
|
|
|
"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs",
|
2013-01-29 08:06:44 +00:00
|
|
|
to,from,true);
|
2013-01-28 01:26:32 +00:00
|
|
|
benchmark(runner,"merc -> lonlat coord transformation (literal)");
|
|
|
|
}
|
|
|
|
|
2013-01-29 22:04:35 +00:00
|
|
|
{
|
|
|
|
test7 runner(10000,100,"([foo]=1)");
|
|
|
|
benchmark(runner,"expression parsing with grammer per parse");
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
test8 runner(10000,100,"([foo]=1)");
|
|
|
|
benchmark(runner,"expression parsing by re-using grammar");
|
|
|
|
}
|
|
|
|
|
2013-09-19 01:47:44 +00:00
|
|
|
// TODO - consider bring back rule cache benchmarks after c++11 is in master
|
|
|
|
// previously test 9/10
|
2013-02-21 20:36:16 +00:00
|
|
|
|
2013-09-17 10:59:38 +00:00
|
|
|
// polygon/rect clipping
|
|
|
|
// IN : POLYGON ((155 203, 233 454, 315 340, 421 446, 463 324, 559 466, 665 253, 528 178, 394 229, 329 138, 212 134, 183 228, 200 264, 155 203),(313 190, 440 256, 470 248, 510 305, 533 237, 613 263, 553 397, 455 262, 405 378, 343 287, 249 334, 229 191, 313 190))
|
|
|
|
// RECT : POLYGON ((181 106, 181 470, 631 470, 631 106, 181 106))
|
|
|
|
// OUT (expected)
|
|
|
|
// POLYGON ((181 286.6666666666667, 233 454, 315 340, 421 446, 463 324, 559 466, 631 321.3207547169811, 631 234.38686131386862, 528 178, 394 229, 329 138, 212 134, 183 228, 200 264, 181 238.24444444444444, 181 286.6666666666667),(313 190, 440 256, 470 248, 510 305, 533 237, 613 263, 553 397, 455 262, 405 378, 343 287, 249 334, 229 191, 313 190))
|
|
|
|
|
|
|
|
mapnik::box2d<double> clipping_box(181,106,631,470);
|
2013-10-02 22:14:52 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
std::string filename_("benchmark/data/polygon.wkt");
|
|
|
|
std::ifstream in(filename_.c_str(),std::ios_base::in | std::ios_base::binary);
|
|
|
|
if (!in.is_open())
|
|
|
|
throw std::runtime_error("could not open: '" + filename_ + "'");
|
|
|
|
std::string wkt_in( (std::istreambuf_iterator<char>(in) ),
|
|
|
|
(std::istreambuf_iterator<char>()) );
|
|
|
|
test11a runner(10000,10,wkt_in,clipping_box);
|
|
|
|
benchmark(runner,"clipping polygon with conv_clip_polygon");
|
|
|
|
}
|
|
|
|
|
2013-02-28 00:18:28 +00:00
|
|
|
{
|
|
|
|
std::string filename_("benchmark/data/polygon.wkt");
|
|
|
|
std::ifstream in(filename_.c_str(),std::ios_base::in | std::ios_base::binary);
|
|
|
|
if (!in.is_open())
|
|
|
|
throw std::runtime_error("could not open: '" + filename_ + "'");
|
|
|
|
std::string wkt_in( (std::istreambuf_iterator<char>(in) ),
|
|
|
|
(std::istreambuf_iterator<char>()) );
|
2013-09-17 10:59:38 +00:00
|
|
|
test11 runner(10000,10,wkt_in,clipping_box);
|
2013-02-28 00:18:28 +00:00
|
|
|
benchmark(runner,"clipping polygon with agg_conv_clipper");
|
|
|
|
}
|
|
|
|
|
2013-10-02 22:14:52 +00:00
|
|
|
|
2013-03-14 09:30:41 +00:00
|
|
|
{
|
|
|
|
std::string filename_("benchmark/data/polygon.wkt");
|
|
|
|
std::ifstream in(filename_.c_str(),std::ios_base::in | std::ios_base::binary);
|
|
|
|
if (!in.is_open())
|
|
|
|
throw std::runtime_error("could not open: '" + filename_ + "'");
|
|
|
|
std::string wkt_in( (std::istreambuf_iterator<char>(in) ),
|
|
|
|
(std::istreambuf_iterator<char>()) );
|
2013-09-17 10:59:38 +00:00
|
|
|
test12 runner(10000,10,wkt_in,clipping_box);
|
2013-03-14 09:30:41 +00:00
|
|
|
benchmark(runner,"clipping polygon with mapnik::polygon_clipper");
|
|
|
|
}
|
|
|
|
|
2013-04-03 12:52:54 +00:00
|
|
|
{
|
2013-07-04 18:31:46 +00:00
|
|
|
bool success = mapnik::freetype_engine::register_fonts("./fonts", true);
|
|
|
|
if (!success) {
|
|
|
|
std::clog << "warning, did not register any new fonts!\n";
|
|
|
|
}
|
2013-04-03 13:17:18 +00:00
|
|
|
unsigned face_count = mapnik::freetype_engine::face_names().size();
|
2013-04-03 12:52:54 +00:00
|
|
|
test13 runner(1000,10);
|
2013-10-02 22:14:52 +00:00
|
|
|
benchmark(runner, (boost::format("font_engine: created %ld faces in ") % (face_count * 1000 * 10)).str());
|
2013-04-03 12:52:54 +00:00
|
|
|
}
|
2013-10-02 22:14:52 +00:00
|
|
|
|
2013-10-02 23:09:32 +00:00
|
|
|
{
|
|
|
|
test14 runner(500,10,
|
|
|
|
"benchmark/data/polygon_rendering_clip.xml",
|
|
|
|
mapnik::box2d<double>(-20037508.3428,-8317435.0606,20037508.3428,18399242.7298));
|
|
|
|
benchmark(runner, "rendering polygon with clipping at full extent");
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
test14 runner(500,10,
|
|
|
|
"benchmark/data/polygon_rendering_no_clip.xml",
|
|
|
|
mapnik::box2d<double>(-20037508.3428,-8317435.0606,20037508.3428,18399242.7298));
|
|
|
|
benchmark(runner, "rendering polygon without clipping at full extent");
|
2013-04-03 12:52:54 +00:00
|
|
|
}
|
2013-10-02 23:09:32 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
// note: bbox below is for 16/10491/22911.png
|
|
|
|
test14 runner(500,10,
|
|
|
|
"benchmark/data/polygon_rendering_clip.xml",
|
|
|
|
mapnik::box2d<double>(-13622912.929097254,6026906.8062295765,-13621689.93664469,6028129.79868214));
|
|
|
|
benchmark(runner, "rendering polygon with clipping at z16 extent");
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
test14 runner(500,10,
|
|
|
|
"benchmark/data/polygon_rendering_no_clip.xml",
|
|
|
|
mapnik::box2d<double>(-13622912.929097254,6026906.8062295765,-13621689.93664469,6028129.79868214));
|
|
|
|
benchmark(runner, "rendering polygon without clipping at z16 extent");
|
|
|
|
}
|
|
|
|
|
2013-01-09 03:07:11 +00:00
|
|
|
std::cout << "...benchmark done\n";
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
catch (std::exception const& ex)
|
|
|
|
{
|
|
|
|
std::clog << "test error: " << ex.what() << "\n";
|
|
|
|
return -1;
|
|
|
|
}
|
2013-01-21 18:31:16 +00:00
|
|
|
}
|