<s> """<STR_LIT>""" <EOL> import cProfile <EOL> import inspect <EOL> import timeit <EOL> from line_profiler import LineProfiler <EOL> from pikos . monitors . function_monitor import FunctionRecord , FunctionMonitor <EOL> from pikos . benchmark . record_counter import RecordCounter <EOL> cevent = '<STR_LIT:_>' <EOL> class FunctionContainer ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> self . _index = <NUM_LIT:0> <EOL> self . _recorder = RecordCounter ( ) <EOL> self . namedtuple_record = FunctionRecord <EOL> self . tuple_record = lambda * x : x <EOL> def original_method ( self , frame , event , arg ) : <EOL> """<STR_LIT>""" <EOL> filename , lineno , function , _ , _ = inspect . getframeinfo ( frame , context = <NUM_LIT:0> ) <EOL> if event . startswith ( '<STR_LIT>' ) : <EOL> function = arg . __name__ <EOL> record = FunctionRecord ( self . _index , event , function , lineno , filename ) <EOL> self . _recorder . record ( record ) <EOL> self . _index += <NUM_LIT:1> <EOL> def step_one ( self , frame , event , arg ) : <EOL> """<STR_LIT>""" <EOL> lineno = frame . f_lineno <EOL> code = frame . f_code <EOL> filename = code . co_filename <EOL> if event . startswith ( '<STR_LIT>' ) : <EOL> function = arg . __name__ <EOL> else : <EOL> function = code . co_name <EOL> record = FunctionRecord ( self . _index , event , function , lineno , filename ) <EOL> self . _recorder . record ( record ) <EOL> self . _index += <NUM_LIT:1> <EOL> def step_two ( self , frame , event , arg ) : <EOL> """<STR_LIT>""" <EOL> lineno = frame . f_lineno <EOL> code = frame . f_code <EOL> filename = code . co_filename <EOL> if '<STR_LIT>' == event [ : <NUM_LIT:2> ] : <EOL> function = arg . __name__ <EOL> else : <EOL> function = code . co_name <EOL> record = FunctionRecord ( <EOL> self . _index , event , function , lineno , filename ) <EOL> self . _recorder . record ( record ) <EOL> self . _index += <NUM_LIT:1> <EOL> def step_three ( self , frame , event , arg ) : <EOL> """<STR_LIT>""" <EOL> code = frame . f_code <EOL> if '<STR_LIT>' == event [ : <NUM_LIT:2> ] : <EOL> record = FunctionRecord ( <EOL> self . _index , event , arg . __name__ , <EOL> frame . f_lineno , code . co_filename ) <EOL> else : <EOL> record = FunctionRecord ( <EOL> self . _index , event , code . co_name , <EOL> frame . f_lineno , code . co_filename ) <EOL> self . _recorder . record ( record ) <EOL> self . _index += <NUM_LIT:1> <EOL> def step_four ( self , frame , event , arg ) : <EOL> """<STR_LIT>""" <EOL> if '<STR_LIT>' == event [ : <NUM_LIT:2> ] : <EOL> record = FunctionRecord ( <EOL> self . _index , event , arg . __name__ , <EOL> frame . f_lineno , frame . f_code . co_filename ) <EOL> else : <EOL> code = frame . f_code <EOL> record = FunctionRecord ( <EOL> self . _index , event , code . co_name , <EOL> frame . f_lineno , code . co_filename ) <EOL> self . _recorder . record ( record ) <EOL> self . _index += <NUM_LIT:1> <EOL> def step_five ( self , frame , event , arg ) : <EOL> """<STR_LIT>""" <EOL> if '<STR_LIT>' == event [ : <NUM_LIT:2> ] : <EOL> record = self . namedtuple_record ( <EOL> self . _index , event , arg . __name__ , <EOL> frame . f_lineno , frame . f_code . co_filename ) <EOL> else : <EOL> code = frame . f_code <EOL> record = self . namedtuple_record ( <EOL> self . _index , event , code . co_name , <EOL> frame . f_lineno , code . co_filename ) <EOL> self . _recorder . record ( record ) <EOL> self . _index += <NUM_LIT:1> <EOL> def step_six ( self , frame , event , arg ) : <EOL> """<STR_LIT>""" <EOL> if '<STR_LIT>' == event [ : <NUM_LIT:2> ] : <EOL> record = self . tuple_record ( <EOL> self . _index , event , arg . __name__ , <EOL> frame . f_lineno , frame . f_code . co_filename ) <EOL> else : <EOL> code = frame . f_code <EOL> record = self . tuple_record ( <EOL> self . _index , event , code . co_name , <EOL> frame . f_lineno , code . co_filename ) <EOL> self . _recorder . record ( record ) <EOL> self . _index += <NUM_LIT:1> <EOL> def step_seven ( self , frame , event , arg ) : <EOL> """<STR_LIT>""" <EOL> if '<STR_LIT>' == event [ : <NUM_LIT:2> ] : <EOL> record = ( <EOL> self . _index , event , arg . __name__ , <EOL> frame . f_lineno , frame . f_code . co_filename ) <EOL> else : <EOL> code = frame . f_code <EOL> record = ( <EOL> self . _index , event , code . co_name , <EOL> frame . f_lineno , code . co_filename ) <EOL> self . _recorder . record ( record ) <EOL> self . _index += <NUM_LIT:1> <EOL> class CurrentFunctionContainer ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> monitor = FunctionMonitor ( recorder = RecordCounter ( ) , record_type = tuple ) <EOL> self . current = monitor . on_function_event <EOL> class SlotsFunctionContainer ( object ) : <EOL> """<STR_LIT>""" <EOL> __slots__ = ( '<STR_LIT:index>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def __init__ ( self ) : <EOL> self . index = <NUM_LIT:0> <EOL> self . _recorder = RecordCounter ( ) <EOL> self . record = self . _recorder . record <EOL> def step_eight ( self , frame , event , arg ) : <EOL> """<STR_LIT>""" <EOL> if '<STR_LIT:_>' == event [ <NUM_LIT:1> ] : <EOL> record = ( <EOL> self . index , event , arg . __name__ , <EOL> frame . f_lineno , frame . f_code . co_filename ) <EOL> else : <EOL> code = frame . f_code <EOL> record = ( <EOL> self . index , event , code . co_name , <EOL> frame . f_lineno , code . co_filename ) <EOL> self . _recorder . record ( record ) <EOL> self . index += <NUM_LIT:1> <EOL> def step_nine ( self , frame , event , arg ) : <EOL> """<STR_LIT>""" <EOL> if '<STR_LIT:_>' == event [ <NUM_LIT:1> ] : <EOL> record = ( <EOL> self . index , event , arg . __name__ , <EOL> frame . f_lineno , frame . f_code . co_filename ) <EOL> else : <EOL> code = frame . f_code <EOL> record = ( <EOL> self . index , event , code . co_name , <EOL> frame . f_lineno , code . co_filename ) <EOL> self . record ( record ) <EOL> self . index += <NUM_LIT:1> <EOL> method_map = [ <EOL> ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , FunctionContainer ) , <EOL> ( [ '<STR_LIT>' , '<STR_LIT>' ] , SlotsFunctionContainer ) , <EOL> ( [ '<STR_LIT>' ] , CurrentFunctionContainer ) ] <EOL> def function_runner ( method_name , number = <NUM_LIT> ) : <EOL> """<STR_LIT>""" <EOL> for method_names , cls in method_map : <EOL> if method_name in method_names : <EOL> break <EOL> else : <EOL> raise ValueError ( '<STR_LIT>' . format ( method_name ) ) <EOL> monitor = cls ( ) <EOL> method = getattr ( monitor , method_name ) <EOL> frame = inspect . currentframe ( ) <EOL> for i in range ( number ) : <EOL> method ( frame , '<STR_LIT>' , method ) <EOL> for i in range ( number ) : <EOL> method ( frame , '<STR_LIT>' , method ) <EOL> for i in range ( number ) : <EOL> method ( frame , '<STR_LIT>' , method ) <EOL> for i in range ( number ) : <EOL> method ( frame , '<STR_LIT>' , method ) <EOL> for i in range ( number ) : <EOL> method ( frame , '<STR_LIT>' , method ) <EOL> for i in range ( number ) : <EOL> method ( frame , '<STR_LIT>' , method ) <EOL> def main ( ) : <EOL> profiler = cProfile . Profile ( ) <EOL> profiler . enable ( ) <EOL> function_runner ( '<STR_LIT>' ) <EOL> function_runner ( '<STR_LIT>' ) <EOL> function_runner ( '<STR_LIT>' ) <EOL> function_runner ( '<STR_LIT>' ) <EOL> function_runner ( '<STR_LIT>' ) <EOL> function_runner ( '<STR_LIT>' ) <EOL> function_runner ( '<STR_LIT>' ) <EOL> function_runner ( '<STR_LIT>' ) <EOL> function_runner ( '<STR_LIT>' ) <EOL> function_runner ( '<STR_LIT>' ) <EOL> function_runner ( '<STR_LIT>' ) <EOL> profiler . disable ( ) <EOL> profiler . dump_stats ( '<STR_LIT>' ) <EOL> line_profiler = LineProfiler ( CurrentFunctionContainer ( ) . current ) <EOL> line_profiler . enable ( ) <EOL> function_runner ( '<STR_LIT>' ) <EOL> line_profiler . disable ( ) <EOL> line_profiler . dump_stats ( '<STR_LIT>' ) <EOL> line_profiler . print_stats ( ) <EOL> print '<STR_LIT>' , timeit . timeit ( <EOL> lambda : function_runner ( '<STR_LIT>' ) , number = <NUM_LIT:7> ) <EOL> print '<STR_LIT>' , timeit . timeit ( <EOL> lambda : function_runner ( '<STR_LIT>' ) , number = <NUM_LIT:7> ) <EOL> print '<STR_LIT>' , timeit . timeit ( <EOL> lambda : function_runner ( '<STR_LIT>' ) , number = <NUM_LIT:7> ) <EOL> print '<STR_LIT>' , timeit . timeit ( <EOL> lambda : function_runner ( '<STR_LIT>' ) , number = <NUM_LIT:7> ) <EOL> print '<STR_LIT>' , timeit . timeit ( <EOL> lambda : function_runner ( '<STR_LIT>' ) , number = <NUM_LIT:7> ) <EOL> print '<STR_LIT>' , timeit . timeit ( <EOL> lambda : function_runner ( '<STR_LIT>' ) , number = <NUM_LIT:7> ) <EOL> print '<STR_LIT>' , timeit . timeit ( <EOL> lambda : function_runner ( '<STR_LIT>' ) , number = <NUM_LIT:7> ) <EOL> print '<STR_LIT>' , timeit . timeit ( <EOL> lambda : function_runner ( '<STR_LIT>' ) , number = <NUM_LIT:7> ) <EOL> print '<STR_LIT>' , timeit . timeit ( <EOL> lambda : function_runner ( '<STR_LIT>' ) , number = <NUM_LIT:7> ) <EOL> print '<STR_LIT>' , timeit . timeit ( <EOL> lambda : function_runner ( '<STR_LIT>' ) , number = <NUM_LIT:7> ) <EOL> print '<STR_LIT>' , timeit . timeit ( <EOL> lambda : function_runner ( '<STR_LIT>' ) , number = <NUM_LIT:7> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
