contrib/perf.py
changeset 31823 f6d77af84ef3
parent 31483 413b44003462
child 32246 ded48ad55146
equal deleted inserted replaced
31822:fde4822b0102 31823:f6d77af84ef3
    63 # available since 1.9.3 (or 94b200a11cf7)
    63 # available since 1.9.3 (or 94b200a11cf7)
    64 _undefined = object()
    64 _undefined = object()
    65 def safehasattr(thing, attr):
    65 def safehasattr(thing, attr):
    66     return getattr(thing, attr, _undefined) is not _undefined
    66     return getattr(thing, attr, _undefined) is not _undefined
    67 setattr(util, 'safehasattr', safehasattr)
    67 setattr(util, 'safehasattr', safehasattr)
       
    68 
       
    69 # for "historical portability":
       
    70 # define util.timer forcibly, because util.timer has been available
       
    71 # since ae5d60bb70c9
       
    72 if safehasattr(time, 'perf_counter'):
       
    73     util.timer = time.perf_counter
       
    74 elif os.name == 'nt':
       
    75     util.timer = time.clock
       
    76 else:
       
    77     util.timer = time.time
    68 
    78 
    69 # for "historical portability":
    79 # for "historical portability":
    70 # use locally defined empty option list, if formatteropts isn't
    80 # use locally defined empty option list, if formatteropts isn't
    71 # available, because commands.formatteropts has been available since
    81 # available, because commands.formatteropts has been available since
    72 # 3.2 (or 7a7eed5176a4), even though formatting itself has been
    82 # 3.2 (or 7a7eed5176a4), even though formatting itself has been