@@ -152,19 +152,27 @@ def do_tests():
152152 saveto = '' )
153153 return numpy .asarray (l )
154154
155+ # Initialize test count and results dictionnary
156+ test_total = 0
157+ times_dic = {}
158+
155159 #test in float64 in FAST_RUN mode on the cpu
156160 import theano
157161 if do_float64 :
158162 theano .config .floatX = 'float64'
159163 theano .config .mode = 'FAST_RUN'
160164 float64_times = do_tests ()
165+ times_dic ['float64' ] = float64_times
166+ test_total += numpy .size (float64_times )
161167 print (algo_executed , file = sys .stderr )
162168 print ('float64 times' , float64_times , file = sys .stderr )
163169
164170 #test in float32 in FAST_RUN mode on the cpu
165171 theano .config .floatX = 'float32'
166172 if do_float32 :
167173 float32_times = do_tests ()
174+ times_dic ['float32' ] = float32_times
175+ test_total += numpy .size (float32_times )
168176 print (algo_executed , file = sys .stderr )
169177 print ('float32 times' , float32_times , file = sys .stderr )
170178
@@ -186,6 +194,8 @@ def do_tests():
186194 if do_gpu :
187195 theano .sandbox .cuda .use ('gpu' )
188196 gpu_times = do_tests ()
197+ times_dic ['gpu' ] = gpu_times
198+ test_total += numpy .size (gpu_times )
189199 print (algo_executed , file = sys .stderr )
190200 print ('gpu times' , gpu_times , file = sys .stderr )
191201
@@ -213,30 +223,18 @@ def do_tests():
213223 if do_float32 and do_gpu :
214224 print ('float32/gpu' , float32_times / gpu_times , file = sys .stderr )
215225
216- # Write JUnit xml for speed test performance report
217-
218- speed_file = 'speedtests_time.xml'
219-
220- # Define speed test file write method
221- def write_junit (filename , algos , times , label ):
222- with open (filename , 'a' ) as f :
223- for algo , time in zip (algos , times ):
224- f .write (' <testcase classname="{label}" name="{algo}" time="{time}">'
225- .format (label = label , algo = algo , time = time ))
226- f .write (' </testcase>\n ' )
227-
228- test_total = numpy .size (float64_times ) \
229- + numpy .size (float32_times ) \
230- + numpy .size (gpu_times )
231-
232- with open (speed_file , 'w' ) as f :
226+ # Generate JUnit performance report
227+ # Define speedtest file write method
228+ def write_junit (f , algos , times , label ):
229+ for algo , time in zip (algos , times ):
230+ f .write (' <testcase classname="{label}" name="{algo}" time="{time}">'
231+ .format (label = label , algo = algo , time = time ))
232+ f .write (' </testcase>\n ' )
233+
234+ with open ('speedtests_time.xml' , 'w' ) as f :
233235 f .write ('<?xml version="1.0" encoding="UTF-8"?>\n ' )
234- f .write ('<testsuite name="theano_speedtests" tests="{ntests}">\n '
235- .format (ntests = numpy .size (test_total )))
236-
237- write_junit (speed_file , algo_executed , float64_times , label = 'float64' )
238- write_junit (speed_file , algo_executed , float32_times , label = 'float32' )
239- write_junit (speed_file , algo_executed , gpu_times , label = 'gpu' )
240-
241- with open (speed_file , 'a' ) as f :
236+ f .write ('<testsuite name="dlt_speedtests" tests="{ntests}">\n '
237+ .format (ntests = test_total ))
238+ for label , times in times_dic .items ():
239+ write_junit (f , algo_executed , times , label )
242240 f .write ('</testsuite>\n ' )
0 commit comments