brendankenny/libtess.js — pull request #10 by bcamper (2014-11-13 23:04:13+00:00)
Title: Add simple benchmark for OpenStreetMap polygons

Re: issue #4, this is a simple benchmark for OpenStreetMap polygons, based on the libtess.js triangulation example (could certainly be improved if integrated into the newer test framework you've setup). This was the easiest way to get it up and running, feel free to take or change whichever pieces you want!

Polygons are sourced from [Mapzen's Vector Tile Service](http://mapzen.com/vector), which serves OSM polygons commonly used for rendering (buildings, land & water areas, etc.). This does benchmarks for 4 sets of polygons, one for each zoom level from 14 to 17, all centered on the same lat-lng in Midtown Manhattan. For each zoom level, polygons are simplified to a precision of 1 pixel (assuming a device pixel density of 1). Higher zoom levels have fewer polygons with more vertices each, lower zoom levels have more polygons with fewer vertices each. The benchmark is set to tessellate each polygon set 10 times.

Other notes affecting performance:

- Each vertex is stored as a separate JS array, [x, y]. In the other examples, it looks like vertices have been flattened into one array. But for rendering in [Tangram](http://github.com/tangrams/tangram), we receive geometries as GeoJSON; we could flatten the array before tessellation (and should if this is more performant!), though then we would probably also want to incorporate that time into the benchmark (to reflect how this source data can be used in real-world applications anyway). We could also serve data in a flattened list, but for now wanted this benchmark to reflect the lower common denominator of using GeoJSON source data.

- After tessellation, final vertices are converted to a `Float32Array`. This also isn't strictly a tessellation step, but again reflects real-world use for WebGL.

Questions/ideas, let me know.