Skip to content

Commit

Permalink
Add additional benchmarks (pygeos/pygeos#145)
Browse files Browse the repository at this point in the history
- IO operations (to and from WKT and WKB)
- Geometry construction
  • Loading branch information
clncy committed May 30, 2020
1 parent a851176 commit 723ed67
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions benchmarks/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,41 @@ def time_distance(self):

def time_intersection(self):
pygeos.intersection(self.points, self.polygon)


class IOSuite:
"""Benchmarks I/O operations (WKT and WKB) on a set of 10000 polygons"""
def setup(self):
self.to_write = pygeos.polygons(np.random.random((10000, 100, 2)))
self.to_read_wkt = pygeos.to_wkt(self.to_write)
self.to_read_wkb = pygeos.to_wkb(self.to_write)

def time_write_to_wkt(self):
pygeos.to_wkt(self.to_write)

def time_write_to_wkb(self):
pygeos.to_wkb(self.to_write)

def time_read_from_wkt(self):
pygeos.from_wkt(self.to_read_wkt)

def time_read_from_wkb(self):
pygeos.from_wkb(self.to_read_wkb)


class ConstructiveSuite:
"""Benchmarks constructive functions on a set of 10,000 points"""
def setup(self):
self.points = pygeos.points(np.random.random((10000, 2)))

def time_voronoi_polygons(self):
pygeos.voronoi_polygons(self.points)

def time_envelope(self):
pygeos.envelope(self.points)

def time_convex_hull(self):
pygeos.convex_hull(self.points)

def time_delaunay_triangles(self):
pygeos.delaunay_triangles(self.points)

0 comments on commit 723ed67

Please sign in to comment.