On 2021-01-10 at 18:38:12 +0100, Alex Prengère <alexpreng...@gmail.com> wrote:
> Today I had a quite simple need, I am unsure about the best way to do > it, and saw a possible improvement for the *timeit *module. > > I have about 30 Python scripts and I want to measure precisely their > execution times, without measuring the interpreter startup time, because > for most of them it is quite short (<1ms). Are you solving the right problem? If starting up the interpreter dominates actual wall clock execution time and/or user time in your computer, then why are you concerned with the scripts' execution time? And if you're trying to determine the fastest way to build a piece of a larger process, will your measurements carry forward into that larger process? In other words, if Script One runs in X milliseconds all by itself, will it also run in X milliseconds when it's called from a program that's also doing other things? > 3. Use timeit. The scripts have no side effects so repeating their > execution the way timeit does, works for me. The only issue is that, > as far as I know, timeit only allows statements as input parameters, > not the whole script, like for example: > $ python -m timeit --script script.py > 4. Write custom code to import each script. One of those seem like the right solution, depending on why you're measuing what you're measuring. _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/ZLDV6TENWNKFHRQ5WGIZKKCWQGQTFAG4/ Code of Conduct: http://python.org/psf/codeofconduct/