On Tue, 2009-08-18 at 16:41 +0300, Andrii V. Mishkovskyi wrote:
> Hello, fellow mapnik users and/or developers.
>
> Recently I've stumbled upon strange performance issues when using
> Python bindings. After investigating a little I've came to a
> conclusion that rendering map from Python bindings is (at least) twice
> as slow as using C++ to do the same job. To check my assumptions, I've
> created simple test, which renders 250 images of size 768x768.
> Coordinates are being shifted by 0.01 degree for each image, so I'm
> going from somewhere near north France shore to somewhere near
> Cambridge. Aaanyway, just look in the source code, the idea is pretty
> simple -- http://bitbucket.org/mishok13/mapnik-perf-testing/src/
> C++ code was compiled using following command:
> g++ -Wall -O2 -I/usr/include/freetype2 -I/usr/include/mapnik -lagg_pic
> -lmapnik render.cpp -o render 2>&1
>
> So, the timings for these:
> C++ render:
> $ time ./render
>
> real 0m19.766s
> user 0m5.196s
> sys 0m0.636s
>
> Python render:
> $ time ./render.py
>
> real 0m52.883s
> user 0m22.445s
> sys 0m0.844s
>
> As you can see, results are not really satisfying. I'm still resisting
> to just simply use C++, as writing non-library C++ code hurts my
> feelings badly, so if anyone has any clues -- don't hesitate to share
> them with me. :)
> You could also run the tests on your computer and share the results.
The speed difference is due to a bug in the C++ code. You need to
project the co-ordinates before you create the bbox, i.e.
prj.forward(c0x, c0y);
prj.forward(c1x, c1y);
Envelope<double> bbox(c0x, c0y, c1x, c1y);
With this changed I get the following timings which say the python
version is now faster than the C++ (I repeated this and verified it was
consistent).
[jburg...@shark mapnik-perf-testing]$ time ./render.py
real 0m57.730s
user 0m23.179s
sys 0m0.731s
[jburg...@shark mapnik-perf-testing]$ time ./render
real 1m28.892s
user 0m59.408s
sys 0m0.856s
I then commented out the bbox.width() & bbox.height() calls which are
only in the C++ version, now the C++ time runs a couple of seconds
faster than the python:
[jburg...@shark mapnik-perf-testing]$ time ./render
real 0m54.636s
user 0m22.965s
sys 0m0.816s
This was done using a UK import and the default OSM style.
You should probably save the images into files and do some visual sanity
checking to double check they are producing the same output.
Jon
_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users