
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2015-02-28 20:42 byrhettinger, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| timeit_warning.diff | rhettinger,2015-03-02 04:24 | Timeit warning | review | |
| timeit_python_warning_2.diff | serhiy.storchaka,2015-03-17 23:03 | review | ||
| Messages (10) | |||
|---|---|---|---|
| msg236908 -(view) | Author: Raymond Hettinger (rhettinger)*![]() | Date: 2015-02-28 20:42 | |
IPython 3.0 added a useful feature that we ought to consider for inclusion either in timeit.repeat() or in the command-line interface:"""Using %timeit prints warnings if there is at least a 4x difference in timings between the slowest and fastest runs, since this might meant that the multiple runs are not independent of one another.""" | |||
| msg236944 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2015-03-01 08:34 | |
How it looks? | |||
| msg237012 -(view) | Author: Raymond Hettinger (rhettinger)*![]() | Date: 2015-03-02 04:24 | |
See attached | |||
| msg237013 -(view) | Author: Alex Gaynor (alex)*![]() | Date: 2015-03-02 04:26 | |
This seems like it probably will report something useless (and ultimately be disabled) on PyPy, where runs before and after the JIT will display significant variance. | |||
| msg237022 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2015-03-02 06:45 | |
May be add an option to control a warning (e.g. turn it off when Python run with -Wignore)? May be write warning to stderr? | |||
| msg238341 -(view) | Author: Robert Collins (rbcollins)*![]() | Date: 2015-03-17 21:32 | |
I think for PyPI its actually important here - the JIT'd state of the code is essentially global state being mutated - you can't assess how fast the code is without first warming up the JIT, and if it warms up half way through your fastest run, you're still not actually finding out what you might want to find out.E.g. do you want to know: - how fast is this unjitted [e.g. CLI's] - how fast will this be once its hot [e.g. services]Personally, I think as a first approximation, warning about massive variance is a good thing. We could add an option to turn it off, and we could also look at hooking properly into the jit to allow detection of stable state and benchmark only from there on in. But those extra things don't detract from the utility of warning about suspect runs. | |||
| msg238345 -(view) | Author: Robert Collins (rbcollins)*![]() | Date: 2015-03-17 21:53 | |
Reviewed on rietvald. | |||
| msg238356 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2015-03-17 22:43 | |
Here is a patch that emits a warning using the warnings module. The warning is output to stderr and can be suppressed with the -Wignore option, as all other warnings.$ ./python -m timeit -n1 -r 10 -s "import time, random" -- "time.sleep(random.random())"1 loops, best of 10: 79.6 msec per loop:0: UserWarning: These test results likely aren't reliable. The worsttime was more than four times slower than the best time.$ ./python -Wignore -m timeit -n1 -r 10 -s "import time, random" -- "time.sleep(random.random())"1 loops, best of 10: 16.2 msec per loop | |||
| msg238357 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2015-03-17 23:03 | |
Implemented Robert's suggestion.$ ./python -m timeit -n1 -r 10 -s "import time, random" -- "time.sleep(random.random())"1 loops, best of 10: 30.2 msec per loop:0: UserWarning: The test results are likely unreliable. The worsttime (946 msec) was more than four times slower than the best time. | |||
| msg249170 -(view) | Author: Roundup Robot (python-dev)![]() | Date: 2015-08-26 00:40 | |
New changeset2e9cf58c891d by Robert Collins in branch 'default':Issue#23552: Timeit now warns when there is substantial (4x) variancehttps://hg.python.org/cpython/rev/2e9cf58c891d | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:13 | admin | set | github: 67740 |
| 2015-08-26 00:41:52 | rbcollins | set | status: open -> closed stage: patch review -> resolved resolution: fixed versions: + Python 3.6, - Python 3.5 |
| 2015-08-26 00:40:53 | python-dev | set | nosy: +python-dev messages: +msg249170 |
| 2015-03-17 23:04:12 | serhiy.storchaka | set | files: -timeit_python_warning.diff |
| 2015-03-17 23:03:55 | serhiy.storchaka | set | files: +timeit_python_warning_2.diff messages: +msg238357 |
| 2015-03-17 22:43:54 | serhiy.storchaka | set | files: +timeit_python_warning.diff messages: +msg238356 |
| 2015-03-17 21:53:54 | rbcollins | set | messages: +msg238345 stage: patch review |
| 2015-03-17 21:32:11 | rbcollins | set | nosy: +rbcollins messages: +msg238341 |
| 2015-03-02 06:45:55 | serhiy.storchaka | set | messages: +msg237022 |
| 2015-03-02 04:26:18 | alex | set | nosy: +alex,arigo,fijall messages: +msg237013 |
| 2015-03-02 04:24:28 | rhettinger | set | files: +timeit_warning.diff keywords: +patch messages: +msg237012 |
| 2015-03-01 08:34:29 | serhiy.storchaka | set | nosy: +serhiy.storchaka messages: +msg236944 |
| 2015-02-28 20:42:51 | rhettinger | create | |