#NEWLINE# def execs_timeit_2vector( exprs , fname = None ) : #NEWLINE# #INDENT# '\n    exprs is a list of list of expr to evaluate\n    The first level of list is put into different graph section in the same graph.\n    The second level is the expression to put in each section\n    ' #NEWLINE# exp = [ ( 1000.0 , 100000 ) , ( 5000.0 , 50000 ) , ( 10000.0 , 10000 ) , ( 50000.0 , 5000 ) , ( 100000.0 , 2000 ) , ( 1000000.0 , 200 ) , ( 10000000.0 , 10 ) ] #NEWLINE# times = [ ] #NEWLINE# str_expr = [ ] #NEWLINE# for g_exprs in exprs : #NEWLINE# #INDENT# for expr in g_exprs : #NEWLINE# #INDENT# nb_call_scal = 1 #NEWLINE# if isinstance ( expr , tuple ) : #NEWLINE# #INDENT# nb_call_scal = expr [ 1 ] #NEWLINE# expr = expr [ 0 ] #NEWLINE# #UNINDENT# str_expr . append ( expr ) #NEWLINE# time = [ ] #NEWLINE# for ( nb_e , nb_c ) in exp : #NEWLINE# #INDENT# time . append ( timeit_2vector ( nb_element = nb_e , nb_repeat = 3 , nb_call = ( nb_c * nb_call_scal ) , expr = expr , do_amd = False ) ) #NEWLINE# #UNINDENT# times . append ( time ) #NEWLINE# #UNINDENT# #UNINDENT# if ( 'pylab' not in globals ( ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# nb_calls = [ e [ 0 ] for e in nb_calls ] #NEWLINE# legends = [ ] #NEWLINE# colors = [ 'b' , 'r' , 'g' , 'c' , 'm' , 'y' ] #NEWLINE# assert ( len ( colors ) >= len ( times ) ) #NEWLINE# fig = pylab . figure ( ) #NEWLINE# for ( idx , ( time , expr ) ) in enumerate ( zip ( times , str_expr ) ) : #NEWLINE# #INDENT# pylab . subplot ( ( ( 220 + idx ) + 1 ) ) #NEWLINE# pylab . subplots_adjust ( wspace = 0.25 , hspace = 0.25 ) #NEWLINE# speedup = [ ( t [ 'numpy' ] . min ( ) / t [ 'numexpr' ] . min ( ) ) for t in time ] #NEWLINE# pylab . semilogx ( nb_calls , speedup , linewidth = 1.0 , color = 'r' ) #NEWLINE# speedup = [ ( t [ 'numpy' ] . min ( ) / t [ 'theano' ] . min ( ) ) for t in time ] #NEWLINE# pylab . semilogx ( nb_calls , speedup , linewidth = 1.0 , color = 'b' ) #NEWLINE# pylab . grid ( True ) #NEWLINE# if ( ( idx == 2 ) or ( idx == 3 ) ) : #NEWLINE# #INDENT# pylab . xlabel ( 'Dimension of vectors a and b' , fontsize = 15 ) #NEWLINE# #UNINDENT# if ( ( idx == 0 ) or ( idx == 2 ) ) : #NEWLINE# #INDENT# pylab . ylabel ( 'Speed up vs NumPy' , fontsize = 15 ) #NEWLINE# #UNINDENT# pylab . axhline ( y = 1 , linewidth = 1.0 , color = 'black' ) #NEWLINE# pylab . xlim ( 1000.0 , 10000000.0 ) #NEWLINE# pylab . xticks ( [ 1000.0 , 100000.0 , 10000000.0 ] , [ '1e3' , '1e5' , '1e7' ] ) #NEWLINE# pylab . title ( expr ) #NEWLINE# #UNINDENT# if fname : #NEWLINE# #INDENT# fig . savefig ( fname ) #NEWLINE# pylab . clf ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# pylab . show ( )