Created
April 25, 2011 18:02
-
-
Save sgillies/940905 to your computer and use it in GitHub Desktop.
Shapely speedups benchmarks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(gispy-lab)krusty-2:Shapely-1.2 seang$ python speedups-benchmark.py | |
N=10 | |
====== | |
Without speedups | |
74.75 usec/pass | |
With speedups | |
19.80 usec/pass | |
(gispy-lab)krusty-2:Shapely-1.2 seang$ python speedups-benchmark.py | |
N=100 | |
====== | |
Without speedups | |
518.01 usec/pass | |
With speedups | |
27.57 usec/pass | |
(gispy-lab)krusty-2:Shapely-1.2 seang$ python speedups-benchmark.py | |
N=1000 | |
====== | |
Without speedups | |
4939.36 usec/pass | |
With speedups | |
146.21 usec/pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Benchmark of olt's https://github.com/olt/shapely/tree/master/shapely/speedups | |
import array | |
import timeit | |
from shapely.geometry import LineString | |
import shapely.speedups | |
N = 100 # num of vertices | |
M = 100 # num of passes | |
print "N=%s" % N | |
print "======" | |
xs = array.array('d', [i for i in range(N)]) | |
ys = array.array('d', [i for i in range(N)]) | |
coords = zip(xs, ys) | |
s = """ | |
line = LineString(coords) | |
""" | |
t = timeit.Timer( | |
stmt=s, | |
setup='from __main__ import coords, LineString' | |
) | |
# No speedups | |
shapely.speedups.disable() | |
print "Without speedups" | |
print "%.2f usec/pass" % (1000000 * t.timeit(number=M)/M) | |
# With speedups | |
shapely.speedups.enable() | |
print "With speedups" | |
print "%.2f usec/pass" % (1000000 * t.timeit(number=M)/M) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Without speedups, cost of creating a line is proportional to N (number coordinates). With speedups, it's a flatter function of N.