vd benchmark

Tuesday update: A few optimizations has shaved about half off the constant, to 5\ \mu\rm{s}\ n\cdot\log{n}. This was mainly (a) choosing boost::vecS as the out-edge container for the BGL-graph, and (b) choosing std::vector instead of std::set for a temporary variable in the grid-search for the closest facet. I suspect the runtime is dominated by that grid-search. Profiling would tell.

I did some benchmarking of my vd-code. It is supposed to run in O(n\cdot\log{n}) time. Benchmarking turns out to be not so simple. I normally compile without any optimizations, and with a lot of sanity-checks and assert():s all over the code. These checks have worse time-complexity and result in long runtimes with big inputs. Then there are compiler optimization flags like -O or -O3.

I was first running the algorithm by inserting each point from python-code:

which I thought could add some overhead. I also made a version ("batch mode") where we first push all points to c++, and then call a run() method:

but this seems to improve runtime only marginally. Here are the results. Runtimes are divided by n\cdot\log{n}, so ideally all points should fall on a horizontal line. At best the code now runs in about 10-16 microseconds times n\cdot\log{n}.

With 4096 input points the runtime improves from 12s down to 1.3s by turning off sanity-checks and assert():s. It further improves to 0.18s with -O3 and to 0.165s in batch-mode.

As an example, the voronoi diagram for 1000 random points looks like this:

1 reply on “vd benchmark”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.