5
5
from timeit import Timer , time
6
6
7
7
import mapnik
8
-
9
- from .utilities import execution_path , run_all
8
+ from .utilities import execution_path
10
9
11
10
12
11
def setup ():
@@ -60,7 +59,7 @@ def setup():
60
59
iterations = 10
61
60
62
61
63
- def do_encoding ():
62
+ def test_encoding ():
64
63
65
64
global image
66
65
@@ -85,7 +84,7 @@ def blank():
85
84
blank_im = mapnik .Image (512 , 512 )
86
85
for c in combinations :
87
86
t = Timer (blank )
88
- run ( blank , blank_im , c , t )
87
+ yield run , blank , blank_im , c , t
89
88
90
89
if 'solid' in tiles :
91
90
def solid ():
@@ -94,7 +93,7 @@ def solid():
94
93
solid_im .fill (mapnik .Color ("#f2efe9" ))
95
94
for c in combinations :
96
95
t = Timer (solid )
97
- run ( solid , solid_im , c , t )
96
+ yield run , solid , solid_im , c , t
98
97
99
98
if 'many_colors' in tiles :
100
99
def many_colors ():
@@ -103,15 +102,15 @@ def many_colors():
103
102
many_colors_im = mapnik .Image .open ('../data/images/13_4194_2747.png' )
104
103
for c in combinations :
105
104
t = Timer (many_colors )
106
- run ( many_colors , many_colors_im , c , t )
105
+ yield run , many_colors , many_colors_im , c , t
107
106
108
107
if 'aerial_24' in tiles :
109
108
def aerial_24 ():
110
109
return eval ('image.tostring("%s")' % c )
111
110
aerial_24_im = mapnik .Image .open ('../data/images/12_654_1580.png' )
112
111
for c in combinations :
113
112
t = Timer (aerial_24 )
114
- run ( aerial_24 , aerial_24_im , c , t )
113
+ yield run , aerial_24 , aerial_24_im , c , t
115
114
116
115
for key , value in sorted (sortable .items (), key = lambda i : (i [1 ], i [0 ])):
117
116
s = results [key ]
@@ -123,9 +122,3 @@ def aerial_24():
123
122
print (
124
123
'min: %sms | avg: %sms | total: %sms | len: %s <-- %s' %
125
124
(min_ , avg , elapsed , size , name ))
126
-
127
-
128
- if __name__ == "__main__" :
129
- setup ()
130
- do_encoding ()
131
- exit (run_all (eval (x ) for x in dir () if x .startswith ("test_" )))
0 commit comments