<s> """<STR_LIT>""" <EOL> import time <EOL> import py <EOL> from pypy . tool . ansi_print import ansi_log <EOL> log = py . log . Producer ( "<STR_LIT>" ) <EOL> py . log . setconsumer ( "<STR_LIT>" , ansi_log ) <EOL> class Timer ( object ) : <EOL> def __init__ ( self , timer = time . time ) : <EOL> self . events = [ ] <EOL> self . next_even = None <EOL> self . timer = timer <EOL> self . t0 = None <EOL> def start_event ( self , event ) : <EOL> now = self . timer ( ) <EOL> if self . t0 is None : <EOL> self . t0 = now <EOL> self . next_event = event <EOL> self . start_time = now <EOL> def end_event ( self , event ) : <EOL> assert self . next_event == event <EOL> now = self . timer ( ) <EOL> self . events . append ( ( event , now - self . start_time ) ) <EOL> self . next_event = None <EOL> self . tk = now <EOL> def ttime ( self ) : <EOL> try : <EOL> return self . tk - self . t0 <EOL> except AttributeError : <EOL> return <NUM_LIT:0.0> <EOL> def pprint ( self ) : <EOL> """<STR_LIT>""" <EOL> spacing = "<STR_LIT:U+0020>" * ( <NUM_LIT:30> - len ( "<STR_LIT>" ) ) <EOL> total = "<STR_LIT>" % ( spacing , self . ttime ( ) ) <EOL> log . bold ( "<STR_LIT>" ) <EOL> for event , time in self . events : <EOL> spacing = "<STR_LIT:U+0020>" * ( <NUM_LIT:30> - len ( event ) ) <EOL> first = "<STR_LIT>" % ( event , spacing ) <EOL> second = "<STR_LIT>" % ( time , ) <EOL> additional_spaces = "<STR_LIT:U+0020>" * ( len ( total ) - len ( first ) - len ( second ) ) <EOL> log . bold ( "<STR_LIT>" % ( first , additional_spaces , second ) ) <EOL> log . bold ( "<STR_LIT:=>" * len ( total ) ) <EOL> log . bold ( total ) </s>
