#NEWLINE# def bench_python( n = 100000 , pct_overlap = 0.2 , K = 1 ) : #NEWLINE# #INDENT# import gc #NEWLINE# ns = [ 2 , 3 , 4 , 5 , 6 ] #NEWLINE# iterations = 200 #NEWLINE# pct_overlap = 0.2 #NEWLINE# kinds = [ 'outer' , 'left' , 'inner' ] #NEWLINE# all_results = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for logn in ns : #NEWLINE# #INDENT# n = ( 10 ** logn ) #NEWLINE# a = np . arange ( n , dtype = np . int64 ) #NEWLINE# b = np . arange ( ( n * pct_overlap ) , ( ( n * pct_overlap ) + n ) , dtype = np . int64 ) #NEWLINE# avf = np . random . randn ( n , K ) #NEWLINE# bvf = np . random . randn ( n , K ) #NEWLINE# a_frame = DataFrame ( avf , index = a , columns = lrange ( K ) ) #NEWLINE# b_frame = DataFrame ( bvf , index = b , columns = lrange ( K , ( 2 * K ) ) ) #NEWLINE# all_results [ logn ] = result = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for kind in kinds : #NEWLINE# #INDENT# gc . disable ( ) #NEWLINE# elapsed = 0 #NEWLINE# _s = time . clock ( ) #NEWLINE# for i in range ( iterations ) : #NEWLINE# #INDENT# if ( ( i % 10 ) == 0 ) : #NEWLINE# #INDENT# elapsed += ( time . clock ( ) - _s ) #NEWLINE# gc . collect ( ) #NEWLINE# _s = time . clock ( ) #NEWLINE# #UNINDENT# a_frame . join ( b_frame , how = b ) #NEWLINE# #UNINDENT# elapsed += ( time . clock ( ) - _s ) #NEWLINE# gc . enable ( ) #NEWLINE# result [ kind ] = ( ( elapsed / iterations ) * 1000 ) #NEWLINE# #UNINDENT# #UNINDENT# return DataFrame ( all_results , index = kinds )