delfrrr / delaunator-cpp

A really fast C++ library for Delaunay triangulation of 2D points
MIT License
517 stars 98 forks source link

Add 100k/1m uniform random benchmarks #8

Closed mourner closed 6 years ago

mourner commented 6 years ago

@delfrrr Added some more benchmarks (100k and 1m random) in this PR.

Roughly 6 times faster then JS version

I was curious about this statement and loos like it's misleading — benchmarks show only about ~20-30% improvement, not 6x. And I get similar perf numbers to the C++ version in my Rust port https://github.com/mourner/delaunator-rs

mourner commented 6 years ago

@delfrrr can you also fix the misleading statement in the readme about 6x faster than JS, or at least explain how you got this result?

delfrrr commented 6 years ago

@mourner will do soon, need to dig into results; I made current statements based on results from this script https://github.com/delfrrr/delaunator-cpp/blob/master/generate-reference-triangles/index.js

I agree that they may be not precise; also note the version I was testing against;

mourner commented 6 years ago

@delfrrr the script doesn't have any warmup, which is especially important for JS because it's JIT-optimized. It might have also measured a dataset that's too small.

delfrrr commented 6 years ago

I modified cpp and js benchmark to make it more similar; for JS benchmark I removed part where points are transformed to typed array, so results are even slightly better for JS. Also added more samples for CPP

plot 39

I think there is ~30ms overhead in JS version which makes much slower on small number of points. On 1M points difference is ~10%; since time is not growing linear with number of points comparison in percents is not relevant.

@mourner btw, what is estimated complexity of algorithm itself?

mourner commented 6 years ago

@delfrrr it should be O(n log n) in average. The 30ms JS "overhead" is likely just the JIT warmup — subsequent runs on the same amount of points should be much faster.