本文整理汇总了Python中timeit.main方法的典型用法代码示例。如果您正苦于以下问题:Python timeit.main方法的具体用法?Python timeit.main怎么用?Python timeit.main使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类timeit
的用法示例。
在下文中一共展示了timeit.main方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import timeit [as 别名]
# 或者: from timeit import main [as 别名]
def main():
print "unidecode_expect_ascii, ASCII string"
timeit.main([
'-s',
'from unidecode import unidecode_expect_ascii',
'unidecode_expect_ascii(u"Hello, World")'])
print "unidecode_expect_ascii, non-ASCII string"
timeit.main([
'-s',
'from unidecode import unidecode_expect_ascii',
'unidecode_expect_ascii(u"¡Hola mundo!")'])
print "unidecode_expect_nonascii, ASCII string"
timeit.main([
'-s',
'from unidecode import unidecode_expect_nonascii',
'unidecode_expect_nonascii(u"Hello, World")'])
print "unidecode_expect_nonascii, non-ASCII string"
timeit.main([
'-s',
'from unidecode import unidecode_expect_nonascii',
'unidecode_expect_nonascii(u"¡Hola mundo!")'])
示例2: run_main
# 需要导入模块: import timeit [as 别名]
# 或者: from timeit import main [as 别名]
def run_main(self, seconds_per_increment=1.0, switches=None, timer=None):
if timer is None:
timer = FakeTimer(seconds_per_increment=seconds_per_increment)
if switches is None:
args = []
else:
args = switches[:]
args.append(self.fake_stmt)
# timeit.main() modifies sys.path, so save and restore it.
orig_sys_path = sys.path[:]
with captured_stdout() as s:
timeit.main(args=args, _wrap_timer=timer.wrap_timer)
sys.path[:] = orig_sys_path[:]
return s.getvalue()