Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 1 | :mod:`timeit` --- Measure execution time of small code snippets |
| 2 | =============================================================== |
| 3 | |
| 4 | .. module:: timeit |
| 5 | :synopsis: Measure the execution time of small code snippets. |
| 6 | |
| 7 | |
| 8 | .. versionadded:: 2.3 |
| 9 | |
| 10 | .. index:: |
| 11 | single: Benchmarking |
| 12 | single: Performance |
| 13 | |
Éric Araujo | 29a0b57 | 2011-08-19 02:14:03 +0200 | [diff] [blame] | 14 | **Source code:** :source:`Lib/timeit.py` |
| 15 | |
| 16 | -------------- |
| 17 | |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 18 | This module provides a simple way to time small bits of Python code. It has both |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 19 | a :ref:`command-line-interface` as well as a :ref:`callable <python-interface>` |
| 20 | one. It avoids a number of common traps for measuring execution times. |
| 21 | See also Tim Peters' introduction to the "Algorithms" chapter in the *Python |
| 22 | Cookbook*, published by O'Reilly. |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 23 | |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 24 | |
| 25 | Basic Examples |
| 26 | -------------- |
| 27 | |
| 28 | The following example shows how the :ref:`command-line-interface` |
| 29 | can be used to compare three different expressions: |
| 30 | |
| 31 | .. code-block:: sh |
| 32 | |
| 33 | $ python -m timeit '"-".join(str(n) for n in range(100))' |
| 34 | 10000 loops, best of 3: 40.3 usec per loop |
| 35 | $ python -m timeit '"-".join([str(n) for n in range(100)])' |
| 36 | 10000 loops, best of 3: 33.4 usec per loop |
| 37 | $ python -m timeit '"-".join(map(str, range(100)))' |
| 38 | 10000 loops, best of 3: 25.2 usec per loop |
| 39 | |
| 40 | This can be achieved from the :ref:`python-interface` with:: |
| 41 | |
| 42 | >>> import timeit |
| 43 | >>> timeit.timeit('"-".join(str(n) for n in range(100))', number=10000) |
| 44 | 0.8187260627746582 |
| 45 | >>> timeit.timeit('"-".join([str(n) for n in range(100)])', number=10000) |
| 46 | 0.7288308143615723 |
| 47 | >>> timeit.timeit('"-".join(map(str, range(100)))', number=10000) |
| 48 | 0.5858950614929199 |
| 49 | |
| 50 | Note however that :mod:`timeit` will automatically determine the number of |
| 51 | repetitions only when the command-line interface is used. In the |
| 52 | :ref:`timeit-examples` section you can find more advanced examples. |
| 53 | |
| 54 | |
| 55 | .. _python-interface: |
| 56 | |
| 57 | Python Interface |
| 58 | ---------------- |
| 59 | |
| 60 | The module defines three convenience functions and a public class: |
| 61 | |
| 62 | |
| 63 | .. function:: timeit(stmt='pass', setup='pass', timer=<default timer>, number=1000000) |
| 64 | |
| 65 | Create a :class:`Timer` instance with the given statement, *setup* code and |
| 66 | *timer* function and run its :meth:`.timeit` method with *number* executions. |
| 67 | |
| 68 | .. versionadded:: 2.6 |
| 69 | |
| 70 | |
| 71 | .. function:: repeat(stmt='pass', setup='pass', timer=<default timer>, repeat=3, number=1000000) |
| 72 | |
| 73 | Create a :class:`Timer` instance with the given statement, *setup* code and |
| 74 | *timer* function and run its :meth:`.repeat` method with the given *repeat* |
| 75 | count and *number* executions. |
| 76 | |
| 77 | .. versionadded:: 2.6 |
| 78 | |
| 79 | |
| 80 | .. function:: default_timer() |
| 81 | |
| 82 | Define a default timer, in a platform-specific manner. On Windows, |
| 83 | :func:`time.clock` has microsecond granularity, but :func:`time.time`'s |
| 84 | granularity is 1/60th of a second. On Unix, :func:`time.clock` has 1/100th of |
| 85 | a second granularity, and :func:`time.time` is much more precise. On either |
| 86 | platform, :func:`default_timer` measures wall clock time, not the CPU |
| 87 | time. This means that other processes running on the same computer may |
| 88 | interfere with the timing. |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 89 | |
| 90 | |
Ezio Melotti | aea83f5 | 2012-09-20 06:02:50 +0300 | [diff] [blame] | 91 | .. class:: Timer(stmt='pass', setup='pass', timer=<timer function>) |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 92 | |
| 93 | Class for timing execution speed of small code snippets. |
| 94 | |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 95 | The constructor takes a statement to be timed, an additional statement used |
| 96 | for setup, and a timer function. Both statements default to ``'pass'``; |
| 97 | the timer function is platform-dependent (see the module doc string). |
| 98 | *stmt* and *setup* may also contain multiple statements separated by ``;`` |
| 99 | or newlines, as long as they don't contain multi-line string literals. |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 100 | |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 101 | To measure the execution time of the first statement, use the :meth:`.timeit` |
| 102 | method. The :meth:`.repeat` method is a convenience to call :meth:`.timeit` |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 103 | multiple times and return a list of results. |
| 104 | |
| 105 | .. versionchanged:: 2.6 |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 106 | The *stmt* and *setup* parameters can now also take objects that are |
| 107 | callable without arguments. This will embed calls to them in a timer |
| 108 | function that will then be executed by :meth:`.timeit`. Note that the |
| 109 | timing overhead is a little larger in this case because of the extra |
| 110 | function calls. |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 111 | |
| 112 | |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 113 | .. method:: Timer.timeit(number=1000000) |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 114 | |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 115 | Time *number* executions of the main statement. This executes the setup |
| 116 | statement once, and then returns the time it takes to execute the main |
| 117 | statement a number of times, measured in seconds as a float. |
| 118 | The argument is the number of times through the loop, defaulting to one |
| 119 | million. The main statement, the setup statement and the timer function |
| 120 | to be used are passed to the constructor. |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 121 | |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 122 | .. note:: |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 123 | |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 124 | By default, :meth:`.timeit` temporarily turns off :term:`garbage |
| 125 | collection` during the timing. The advantage of this approach is that |
| 126 | it makes independent timings more comparable. This disadvantage is |
| 127 | that GC may be an important component of the performance of the |
| 128 | function being measured. If so, GC can be re-enabled as the first |
| 129 | statement in the *setup* string. For example:: |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 130 | |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 131 | timeit.Timer('for i in xrange(10): oct(i)', 'gc.enable()').timeit() |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 132 | |
| 133 | |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 134 | .. method:: Timer.repeat(repeat=3, number=1000000) |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 135 | |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 136 | Call :meth:`.timeit` a few times. |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 137 | |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 138 | This is a convenience function that calls the :meth:`.timeit` repeatedly, |
| 139 | returning a list of results. The first argument specifies how many times |
| 140 | to call :meth:`.timeit`. The second argument specifies the *number* |
| 141 | argument for :meth:`.timeit`. |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 142 | |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 143 | .. note:: |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 144 | |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 145 | It's tempting to calculate mean and standard deviation from the result |
| 146 | vector and report these. However, this is not very useful. |
| 147 | In a typical case, the lowest value gives a lower bound for how fast |
| 148 | your machine can run the given code snippet; higher values in the |
| 149 | result vector are typically not caused by variability in Python's |
| 150 | speed, but by other processes interfering with your timing accuracy. |
| 151 | So the :func:`min` of the result is probably the only number you |
| 152 | should be interested in. After that, you should look at the entire |
| 153 | vector and apply common sense rather than statistics. |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 154 | |
| 155 | |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 156 | .. method:: Timer.print_exc(file=None) |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 157 | |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 158 | Helper to print a traceback from the timed code. |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 159 | |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 160 | Typical use:: |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 161 | |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 162 | t = Timer(...) # outside the try/except |
| 163 | try: |
| 164 | t.timeit(...) # or t.repeat(...) |
| 165 | except: |
| 166 | t.print_exc() |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 167 | |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 168 | The advantage over the standard traceback is that source lines in the |
| 169 | compiled template will be displayed. The optional *file* argument directs |
| 170 | where the traceback is sent; it defaults to :data:`sys.stderr`. |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 171 | |
| 172 | |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 173 | .. _command-line-interface: |
Sandro Tosi | 3f0f577 | 2012-04-24 18:11:29 +0200 | [diff] [blame] | 174 | |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 175 | Command-Line Interface |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 176 | ---------------------- |
| 177 | |
| 178 | When called as a program from the command line, the following form is used:: |
| 179 | |
| 180 | python -m timeit [-n N] [-r N] [-s S] [-t] [-c] [-h] [statement ...] |
| 181 | |
Éric Araujo | a8132ec | 2010-12-16 03:53:53 +0000 | [diff] [blame] | 182 | Where the following options are understood: |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 183 | |
Éric Araujo | a8132ec | 2010-12-16 03:53:53 +0000 | [diff] [blame] | 184 | .. program:: timeit |
| 185 | |
| 186 | .. cmdoption:: -n N, --number=N |
| 187 | |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 188 | how many times to execute 'statement' |
| 189 | |
Éric Araujo | a8132ec | 2010-12-16 03:53:53 +0000 | [diff] [blame] | 190 | .. cmdoption:: -r N, --repeat=N |
| 191 | |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 192 | how many times to repeat the timer (default 3) |
| 193 | |
Éric Araujo | a8132ec | 2010-12-16 03:53:53 +0000 | [diff] [blame] | 194 | .. cmdoption:: -s S, --setup=S |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 195 | |
Éric Araujo | a8132ec | 2010-12-16 03:53:53 +0000 | [diff] [blame] | 196 | statement to be executed once initially (default ``pass``) |
| 197 | |
| 198 | .. cmdoption:: -t, --time |
| 199 | |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 200 | use :func:`time.time` (default on all platforms but Windows) |
| 201 | |
Éric Araujo | a8132ec | 2010-12-16 03:53:53 +0000 | [diff] [blame] | 202 | .. cmdoption:: -c, --clock |
| 203 | |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 204 | use :func:`time.clock` (default on Windows) |
| 205 | |
Éric Araujo | a8132ec | 2010-12-16 03:53:53 +0000 | [diff] [blame] | 206 | .. cmdoption:: -v, --verbose |
| 207 | |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 208 | print raw timing results; repeat for more digits precision |
| 209 | |
Éric Araujo | a8132ec | 2010-12-16 03:53:53 +0000 | [diff] [blame] | 210 | .. cmdoption:: -h, --help |
| 211 | |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 212 | print a short usage message and exit |
| 213 | |
| 214 | A multi-line statement may be given by specifying each line as a separate |
| 215 | statement argument; indented lines are possible by enclosing an argument in |
| 216 | quotes and using leading spaces. Multiple :option:`-s` options are treated |
| 217 | similarly. |
| 218 | |
| 219 | If :option:`-n` is not given, a suitable number of loops is calculated by trying |
| 220 | successive powers of 10 until the total time is at least 0.2 seconds. |
| 221 | |
Sandro Tosi | 3f0f577 | 2012-04-24 18:11:29 +0200 | [diff] [blame] | 222 | :func:`default_timer` measurations can be affected by other programs running on |
| 223 | the same machine, so |
| 224 | the best thing to do when accurate timing is necessary is to repeat |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 225 | the timing a few times and use the best time. The :option:`-r` option is good |
| 226 | for this; the default of 3 repetitions is probably enough in most cases. On |
| 227 | Unix, you can use :func:`time.clock` to measure CPU time. |
| 228 | |
| 229 | .. note:: |
| 230 | |
| 231 | There is a certain baseline overhead associated with executing a pass statement. |
| 232 | The code here doesn't try to hide it, but you should be aware of it. The |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 233 | baseline overhead can be measured by invoking the program without arguments, and |
| 234 | it might differ between Python versions. Also, to fairly compare older Python |
| 235 | versions to Python 2.3, you may want to use Python's :option:`-O` option for |
| 236 | the older versions to avoid timing ``SET_LINENO`` instructions. |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 237 | |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 238 | |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 239 | .. _timeit-examples: |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 240 | |
| 241 | Examples |
| 242 | -------- |
| 243 | |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 244 | It is possible to provide a setup statement that is executed only once at the beginning: |
| 245 | |
| 246 | .. code-block:: sh |
| 247 | |
| 248 | $ python -m timeit -s 'text = "sample string"; char = "g"' 'char in text' |
| 249 | 10000000 loops, best of 3: 0.0877 usec per loop |
| 250 | $ python -m timeit -s 'text = "sample string"; char = "g"' 'text.find(char)' |
| 251 | 1000000 loops, best of 3: 0.342 usec per loop |
| 252 | |
| 253 | :: |
| 254 | |
| 255 | >>> import timeit |
| 256 | >>> timeit.timeit('char in text', setup='text = "sample string"; char = "g"') |
| 257 | 0.41440500499993504 |
| 258 | >>> timeit.timeit('text.find(char)', setup='text = "sample string"; char = "g"') |
| 259 | 1.7246671520006203 |
| 260 | |
| 261 | The same can be done using the :class:`Timer` class and its methods:: |
| 262 | |
| 263 | >>> import timeit |
| 264 | >>> t = timeit.Timer('char in text', setup='text = "sample string"; char = "g"') |
| 265 | >>> t.timeit() |
| 266 | 0.3955516149999312 |
| 267 | >>> t.repeat() |
| 268 | [0.40193588800002544, 0.3960157959998014, 0.39594301399984033] |
| 269 | |
| 270 | |
| 271 | The following examples show how to time expressions that contain multiple lines. |
| 272 | Here we compare the cost of using :func:`hasattr` vs. :keyword:`try`/:keyword:`except` |
| 273 | to test for missing and present object attributes: |
| 274 | |
| 275 | .. code-block:: sh |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 276 | |
Senthil Kumaran | b8b7172 | 2011-08-06 13:34:30 +0800 | [diff] [blame] | 277 | $ python -m timeit 'try:' ' str.__nonzero__' 'except AttributeError:' ' pass' |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 278 | 100000 loops, best of 3: 15.7 usec per loop |
Senthil Kumaran | b8b7172 | 2011-08-06 13:34:30 +0800 | [diff] [blame] | 279 | $ python -m timeit 'if hasattr(str, "__nonzero__"): pass' |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 280 | 100000 loops, best of 3: 4.26 usec per loop |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 281 | |
Senthil Kumaran | b8b7172 | 2011-08-06 13:34:30 +0800 | [diff] [blame] | 282 | $ python -m timeit 'try:' ' int.__nonzero__' 'except AttributeError:' ' pass' |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 283 | 1000000 loops, best of 3: 1.43 usec per loop |
Senthil Kumaran | b8b7172 | 2011-08-06 13:34:30 +0800 | [diff] [blame] | 284 | $ python -m timeit 'if hasattr(int, "__nonzero__"): pass' |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 285 | 100000 loops, best of 3: 2.23 usec per loop |
| 286 | |
| 287 | :: |
| 288 | |
| 289 | >>> import timeit |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 290 | >>> # attribute is missing |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 291 | >>> s = """\ |
| 292 | ... try: |
| 293 | ... str.__nonzero__ |
| 294 | ... except AttributeError: |
| 295 | ... pass |
| 296 | ... """ |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 297 | >>> timeit.timeit(stmt=s, number=100000) |
| 298 | 0.9138244460009446 |
| 299 | >>> s = "if hasattr(str, '__bool__'): pass" |
| 300 | >>> timeit.timeit(stmt=s, number=100000) |
| 301 | 0.5829014980008651 |
| 302 | >>> |
| 303 | >>> # attribute is present |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 304 | >>> s = """\ |
| 305 | ... try: |
| 306 | ... int.__nonzero__ |
| 307 | ... except AttributeError: |
| 308 | ... pass |
| 309 | ... """ |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 310 | >>> timeit.timeit(stmt=s, number=100000) |
| 311 | 0.04215312199994514 |
| 312 | >>> s = "if hasattr(int, '__bool__'): pass" |
| 313 | >>> timeit.timeit(stmt=s, number=100000) |
| 314 | 0.08588060699912603 |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 315 | |
| 316 | To give the :mod:`timeit` module access to functions you define, you can pass a |
Ezio Melotti | aea83f5 | 2012-09-20 06:02:50 +0300 | [diff] [blame] | 317 | *setup* parameter which contains an import statement:: |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 318 | |
| 319 | def test(): |
Senthil Kumaran | b8b7172 | 2011-08-06 13:34:30 +0800 | [diff] [blame] | 320 | """Stupid test function""" |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 321 | L = [] |
| 322 | for i in range(100): |
| 323 | L.append(i) |
| 324 | |
Senthil Kumaran | b8b7172 | 2011-08-06 13:34:30 +0800 | [diff] [blame] | 325 | if __name__ == '__main__': |
Ezio Melotti | 31a9e83 | 2012-10-02 05:34:38 +0300 | [diff] [blame] | 326 | import timeit |
| 327 | print(timeit.timeit("test()", setup="from __main__ import test")) |