Hacked By AnonymousFox
�
��fk0 c @ s d Z d d l Z d d l Z d d l Z y d d l Z Wn e k
rT d Z Yn Xd g Z d Z d Z d Z
e j Z d Z
d d � Z d
d � Z Gd d � d � Z d
d
e e d d � Z d
d
e e
e d d � Z d d d d d �Z e d k re j e � � n d S( u� Tool for measuring execution time of small code snippets.
This module avoids a number of common traps for measuring execution
times. See also Tim Peters' introduction to the Algorithms chapter in
the Python Cookbook, published by O'Reilly.
Library usage: see the Timer class.
Command line usage:
python timeit.py [-n N] [-r N] [-s S] [-t] [-c] [-p] [-h] [--] [statement]
Options:
-n/--number N: how many times to execute 'statement' (default: see below)
-r/--repeat N: how many times to repeat the timer (default 3)
-s/--setup S: statement to be executed once initially (default 'pass')
-p/--process: use time.process_time() (default is time.perf_counter())
-t/--time: use time.time() (deprecated)
-c/--clock: use time.clock() (deprecated)
-v/--verbose: print raw timing results; repeat for more digits precision
-h/--help: print this usage message and exit
--: separate options from statement, use when statement starts with -
statement: statement to be timed (default 'pass')
A multi-line statement may be given by specifying each line as a
separate argument; indented lines are possible by enclosing an
argument in quotes and using leading spaces. Multiple -s options are
treated similarly.
If -n is not given, a suitable number of loops is calculated by trying
successive powers of 10 until the total time is at least 0.2 seconds.
The difference in default timer function is because on Windows,
clock() has microsecond granularity but time()'s granularity is 1/60th
of a second; on Unix, clock() has 1/100th of a second granularity and
time() is much more precise. On either platform, the default timer
functions measure wall clock time, not the CPU time. This means that
other processes running on the same computer may interfere with the
timing. The best thing to do when accurate timing is necessary is to
repeat the timing a few times and use the best time. The -r option is
good for this; the default of 3 repetitions is probably enough in most
cases. On Unix, you can use clock() to measure CPU time.
Note: there is a certain baseline overhead associated with executing a
pass statement. The code here doesn't try to hide it, but you should
be aware of it. The baseline overhead can be measured by invoking the
program without arguments.
The baseline overhead differs between Python versions! Also, to
fairly compare older Python versions to Python 2.3, you may want to
use python -O for the older versions to avoid timing SET_LINENO
instructions.
i Nu Timeru <timeit-src>i@B i u�
def inner(_it, _timer):
{setup}
_t0 = _timer()
for _i in _it:
{stmt}
_t1 = _timer()
return _t1 - _t0
c C s | j d d d | � S( u* Helper to reindent a multi-line statement.u
u ( u replace( u srcu indent( ( u+ /opt/alt/python33/lib64/python3.3/timeit.pyu reindentU s u reindentc s | � f d d � } | S( u? Create a timer function. Used if the "statement" is a callable.c s9 � � | � } x | D]
} | � q W| � } | | S( N( ( u _itu _timeru _funcu _t0u _iu _t1( u setup( u+ /opt/alt/python33/lib64/python3.3/timeit.pyu inner[ s
u _template_func.<locals>.inner( ( u setupu funcu inner( ( u setupu+ /opt/alt/python33/lib64/python3.3/timeit.pyu _template_funcY s u _template_funcc B s_ | Ee Z d Z d Z d d e d d � Z d d d � Z e d d � Z e
e d d
� Z d S( u TimeruI Class for timing execution speed of small code snippets.
The constructor takes a statement to be timed, an additional
statement used for setup, and a timer function. Both statements
default to 'pass'; the timer function is platform-dependent (see
module doc string).
To measure the execution time of the first statement, use the
timeit() method. The repeat() method is a convenience to call
timeit() multiple times and return a list of results.
The statements may contain newlines, as long as they don't contain
multi-line string literals.
u passc sc | | _ i � t | t � r� t | d � } t | t � rf t | d � } t j d | d | � } n= t | � r� t j d | d d � } | � d <n t d � � | | _ t | t
d � } t | t � � � � d | _
n~ t | � rSd
| _ t | t � r#| � � � f d
d � } n t | � s>t d � � n t | | � | _
n t d � � d
S( u# Constructor. See class doc string.i i u stmtu setupu _setup()u _setupu&