New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convenience API for timeit.main #49691
Comments
For quick and dirty benchmarking, timeit.main() is one of the handiest What would be nice is a convenience function that accepted appropriate 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() |
It would be even better if you could pass a locals or globals |
See related discussion in bpo-2527 and bpo-1397474. |
Close in favour of bpo-6422 - that one at least has a patch :) |
Don't understand how bpo-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...? |
More specifically, bpo-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. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: