This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2009年03月08日 06:02 by ncoghlan, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Messages (6) | |||
|---|---|---|---|
| msg83305 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2009年03月08日 06:02 | |
For quick and dirty benchmarking, timeit.main() is one of the handiest tools out there, but calling it from Python code is a little tedious since you need to construct a fake list of command line arguments in order to call it. What would be nice is a convenience function that accepted appropriate arguments, with timeit.main being refactored to parse the command line arguments and then call the new convenience function. Possible API: def measure(stmt="pass", setup="pass", timer=default_timer, repeat=default_repeat, number=default_number, verbosity=0, precision=3) The new function would cover the latter section of the current main() function, starting from the line "t = Timer(stmt, setup, timer)". |
|||
| msg83309 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2009年03月08日 13:07 | |
It would be even better if you could pass a locals or globals dictionnary instead of the "setup" arg. And even even better if it could implicitly get the locals/globals from the calling frame :-) |
|||
| msg85688 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2009年04月07日 06:47 | |
See related discussion in issue 2527 and issue 1397474. |
|||
| msg164069 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2012年06月26日 12:28 | |
Close in favour of #6422 - that one at least has a patch :) |
|||
| msg313822 - (view) | Author: Jeremy Metz (jmetz) | Date: 2018年03月14日 14:18 | |
Don't understand how #6422 addresses this - would also like to see a more convenient API for timing; at present CLI gives a nice formatted output, and timeit.timeit gives just the raw timing in seconds. Would be easy to implement by simply refactoring main() in to the command line parsing component (first ~ 50 lines from https://github.com/python/cpython/blob/master/Lib/timeit.py#L256 to ~https://github.com/python/cpython/blob/master/Lib/timeit.py#L312 ) and actual timing and printing component, which could then be called via API. Am happy to work this up if this can be reopened...? |
|||
| msg313825 - (view) | Author: Jeremy Metz (jmetz) | Date: 2018年03月14日 15:02 | |
More specifically, #6422 also mentions at least in part this functionality, but the main focus there seems to be the autorange function. Propose splitting these two by reopening this use. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:46 | admin | set | github: 49691 |
| 2018年03月14日 15:02:20 | jmetz | set | messages: + msg313825 |
| 2018年03月14日 14:18:58 | jmetz | set | nosy:
+ jmetz messages: + msg313822 |
| 2012年06月26日 12:45:22 | ncoghlan | set | status: open -> closed |
| 2012年06月26日 12:28:00 | ncoghlan | set | superseder: timeit called from within Python should allow autoranging resolution: duplicate messages: + msg164069 |
| 2012年01月09日 11:11:15 | ssapin | set | nosy:
+ ssapin |
| 2011年07月24日 03:08:21 | eli.bendersky | set | nosy:
+ eli.bendersky |
| 2010年08月09日 04:12:33 | terry.reedy | set | versions: + Python 3.2, - Python 3.1, Python 2.7 |
| 2009年04月07日 06:47:33 | rhettinger | set | assignee: rhettinger -> messages: + msg85688 |
| 2009年03月09日 05:29:39 | rhettinger | set | assignee: rhettinger nosy: + rhettinger |
| 2009年03月08日 13:07:20 | pitrou | set | nosy:
+ pitrou messages: + msg83309 |
| 2009年03月08日 06:02:23 | ncoghlan | create | |