55from timeit import Timer , time
66
77import mapnik
8-
9- from .utilities import execution_path , run_all
8+ from .utilities import execution_path
109
1110
1211def setup ():
@@ -60,7 +59,7 @@ def setup():
6059iterations = 10
6160
6261
63- def do_encoding ():
62+ def test_encoding ():
6463
6564 global image
6665
@@ -85,7 +84,7 @@ def blank():
8584 blank_im = mapnik .Image (512 , 512 )
8685 for c in combinations :
8786 t = Timer (blank )
88- run ( blank , blank_im , c , t )
87+ yield run , blank , blank_im , c , t
8988
9089 if 'solid' in tiles :
9190 def solid ():
@@ -94,7 +93,7 @@ def solid():
9493 solid_im .fill (mapnik .Color ("#f2efe9" ))
9594 for c in combinations :
9695 t = Timer (solid )
97- run ( solid , solid_im , c , t )
96+ yield run , solid , solid_im , c , t
9897
9998 if 'many_colors' in tiles :
10099 def many_colors ():
@@ -103,15 +102,15 @@ def many_colors():
103102 many_colors_im = mapnik .Image .open ('../data/images/13_4194_2747.png' )
104103 for c in combinations :
105104 t = Timer (many_colors )
106- run ( many_colors , many_colors_im , c , t )
105+ yield run , many_colors , many_colors_im , c , t
107106
108107 if 'aerial_24' in tiles :
109108 def aerial_24 ():
110109 return eval ('image.tostring("%s")' % c )
111110 aerial_24_im = mapnik .Image .open ('../data/images/12_654_1580.png' )
112111 for c in combinations :
113112 t = Timer (aerial_24 )
114- run ( aerial_24 , aerial_24_im , c , t )
113+ yield run , aerial_24 , aerial_24_im , c , t
115114
116115 for key , value in sorted (sortable .items (), key = lambda i : (i [1 ], i [0 ])):
117116 s = results [key ]
@@ -123,9 +122,3 @@ def aerial_24():
123122 print (
124123 'min: %sms | avg: %sms | total: %sms | len: %s <-- %s' %
125124 (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