<s> """<STR_LIT>""" <EOL> import coro <EOL> import cPickle <EOL> import time <EOL> MAGIC = '<STR_LIT>' <EOL> def _dump ( p , filename ) : <EOL> f = open ( filename , '<STR_LIT:w>' ) <EOL> f . write ( MAGIC ) <EOL> data = ( p . bench_class . __name__ , p . bench_class ( ) . get_headings ( ) , time . time ( ) ) <EOL> cPickle . dump ( data , f , - <NUM_LIT:1> ) <EOL> data = { } <EOL> for func , bench in p . charges . iteritems ( ) : <EOL> data [ func . as_str ( ) ] = bench . get_data ( ) <EOL> cPickle . dump ( data , f , - <NUM_LIT:1> ) <EOL> data = { } <EOL> for caller , cc in p . call_counts . iteritems ( ) : <EOL> count_data = cc . get ( ) <EOL> result = [ ] <EOL> for callee , count in count_data : <EOL> element = ( callee . as_str ( ) , count ) <EOL> result . append ( element ) <EOL> data [ caller . as_str ( ) ] = result <EOL> cPickle . dump ( data , f , - <NUM_LIT:1> ) <EOL> f . close ( ) <EOL> def go ( fun , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if '<STR_LIT>' in kwargs : <EOL> profile_filename = kwargs [ '<STR_LIT>' ] <EOL> del kwargs [ '<STR_LIT>' ] <EOL> else : <EOL> profile_filename = '<STR_LIT>' <EOL> if '<STR_LIT>' in kwargs : <EOL> profile_bench = kwargs [ '<STR_LIT>' ] <EOL> del kwargs [ '<STR_LIT>' ] <EOL> else : <EOL> profile_bench = coro . rusage_bench <EOL> p = coro . new_profiler ( profile_bench ) <EOL> p . start ( ) <EOL> try : <EOL> return fun ( * args , ** kwargs ) <EOL> finally : <EOL> total_ticks = p . stop ( ) <EOL> user_ticks = _dump ( p , profile_filename ) <EOL> def start ( profile_bench = coro . rusage_bench ) : <EOL> """<STR_LIT>""" <EOL> p = coro . new_profiler ( profile_bench ) <EOL> p . start ( ) <EOL> def stop ( filename = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> p = coro . get_the_profiler ( ) <EOL> p . stop ( ) <EOL> _dump ( p , filename ) <EOL> def tak1 ( x , y , z ) : <EOL> if y >= x : <EOL> return z <EOL> else : <EOL> return tak1 ( <EOL> tak1 ( x - <NUM_LIT:1> , y , z ) , <EOL> tak2 ( y - <NUM_LIT:1> , z , x ) , <EOL> tak2 ( z - <NUM_LIT:1> , x , y ) <EOL> ) <EOL> def tak2 ( x , y , z ) : <EOL> if y >= x : <EOL> return z <EOL> else : <EOL> return tak2 ( <EOL> tak2 ( x - <NUM_LIT:1> , y , z ) , <EOL> tak1 ( y - <NUM_LIT:1> , z , x ) , <EOL> tak1 ( z - <NUM_LIT:1> , x , y ) <EOL> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> go ( tak2 , <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT:6> ) <EOL> print '<STR_LIT>' </s>
