Python timeit.main() Examples

The following are 6 code examples of timeit.main(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module timeit , or try the search function .
Example #1
Source File: benchmark.py    From unidecode with GNU General Public License v2.0 6 votes vote down vote up
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!")']) 
Example #2
Source File: test_timeit.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
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() 
Example #3
Source File: test_timeit.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
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() 
Example #4
Source File: test_timeit.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
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() 
Example #5
Source File: test_timeit.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
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() 
Example #6
Source File: test_timeit.py    From android_universal with MIT License 5 votes vote down vote up
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()