Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 38 lines (32 sloc) 0.714 kb
715456a @sgillies Add new benchmarks showing off the best of osgeo.ogr and Fiona.
sgillies authored
1
2 import timeit
3 from fiona import collection
4 from osgeo import ogr
5
6 PATH = 'docs/data/test_uk.shp'
7 NAME = 'test_uk'
8
9 # Fiona
10 s = """
11 with collection(PATH, "r") as c:
12 for f in c:
13 id = f["id"]
14 """
15 t = timeit.Timer(
16 stmt=s,
17 setup='from __main__ import collection, PATH, NAME'
18 )
19 print "Fiona 0.5"
20 print "%.2f usec/pass" % (1000000 * t.timeit(number=1000)/1000)
21 print
22
23 # OGR
24 s = """
25 source = ogr.Open(PATH)
26 layer = source.GetLayerByName(NAME)
27 for feature in layer:
28 id = feature.GetFID()
29 source.Destroy()
30 """
31 print "osgeo.ogr 1.7.2 (minimum)"
32 t = timeit.Timer(
33 stmt=s,
34 setup='from __main__ import ogr, PATH, NAME'
35 )
36 print "%.2f usec/pass" % (1000000 * t.timeit(number=1000)/1000)
37
Something went wrong with that request. Please try again.