CoCalc Public Filestmp / 2014-11-12-seconds.sagewsOpen in with one click!
Authors: Harald Schilly, ℏal Snyder, William A. Stein
timeit('1+1', seconds=True)
2.09808349609e-07
timeit??
File: /projects/4a5f0542-5873-4eed-a85c-a18c706e8bcd/.sagemathcloud/sage_salvus.py Source: def timeit(*args, **kwds): """ Time execution of a command or block of commands. This command has been enhanced for Salvus so you may use it as a block decorator as well, e.g., %timeit 2+3 and %timeit(number=10, preparse=False) 2^3 and %timeit(preparse=False) [rest of the cell] Here is the original docstring for timeit: """ def go(code, **kwds): print sage.misc.sage_timeit.sage_timeit(code, globals_dict=salvus.namespace, **kwds) if len(args) == 0: return lambda code : go(code, **kwds) else: go(*args)
def mytimeit(*args, **kwds): """ Time execution of a command or block of commands. This command has been enhanced for Salvus so you may use it as a block decorator as well, e.g., %timeit 2+3 and %timeit(number=10, preparse=False) 2^3 and %timeit(preparse=False) [rest of the cell] Here is the original docstring for timeit: """ def go(code): print sage.misc.sage_timeit.sage_timeit(code, globals_dict=salvus.namespace, **kwds) if len(args) == 0: return lambda code : go(code) else: go(*args)
mytimeit('1+1', seconds=True)
2.07901000977e-07
mytimeit('1+1')
625 loops, best of 3: 201 ns per loop
%mytimeit(seconds=False) 1+1
625 loops, best of 3: 202 ns per loop
print sage.misc.sage_timeit.sage_timeit('1+1', globals_dict=globals(), seconds=True)
2.25830078125e-07
%mytimeit(number=10, seconds=True) 2^3
3.09944152832e-07