Re: [spyder] Modify the "show elapsed time" option

2,741 views
Skip to first unread message

Jed Ludlow

unread,
May 24, 2013, 1:12:51 PM5/24/13
to spyderlib
On Fri, May 24, 2013 at 9:17 AM, Aeronaelius wrote:
Dear Spyder developers,

I am a very satisfied user of the Spyder IDE. It looks great and works even better. I use it for all my larger Python assignments and projects. I also greatly enjoy the embedded profiler and pylint. Really superb!

I would however like to propose one minor modification which would greatly simplify testing for run-times. Currently the "show elapsed time" gives us the time since a Python interpreter was started. If I run a script with Spyder I need to remember at which time I pressed F5 and I need to be there when the script finishes to know the exact amount of time it took to run the entire script. I would like to see the "show elapsed time" option modified such that it works like a stopwatch: start from t = 0 when F5 is pressed and hold the timer fixed when a script has finished running.

I know there exist a number of ways to achieve this without modifying the Spyder IDE (use a Python timing function, or use a bash timing function), however I consider this to be a nicer way to achieve it. If there any reasons to reject this proposal I would gladly like to know why and discuss it if possible.


Hello, Aeronaelius.

If you set your script to run in its own dedicated interpreter rather than in the current interactive interpreter you can achieve what you are looking for. With your script open in the editor, hit F6. From the Run Settings dialog that appears, chose "Execute in a new dedicated Python interpreter". Close the dialog and hit F5. The timer will now start at F5 hit and stop when the Python interpreter exits.

Jed

Message has been deleted

Aeronaelius

unread,
May 25, 2013, 6:09:19 AM5/25/13
to spyd...@googlegroups.com
Dear Jed,

Yes that is indeed true. However I also like the option to be able to interact with the interpreter after the script has finished. This way I can still access all variables. In that case the timer keeps on running.

Kind regards,

Aeronaelius

Jed Ludlow

unread,
May 25, 2013, 7:40:49 PM5/25/13
to spyderlib
Today, Spyder simply monitors the time since each interpreter was born, and I can't honestly think of any sane way that we could modify that behavior so that it reliably predicts the particular portion of the input commands it is supposed to time. I would suggest inserting repeated calls to time.time() into your script and then take the difference.


  

Aeronaelius

unread,
May 27, 2013, 7:33:42 AM5/27/13
to spyd...@googlegroups.com
Well, what I want is already possible in a way. Like you said by setting the script to run in its own dedicated interpreter the timer starts when the interpreter is born and stops when the script is finished. However that is only possible IF you do not add the option to interact with the interpreter after the script has finished (as I said before). So basically what could be done is to do the same for when the interaction option is selected.

Another way is to make Spyder print the elapsed time to the console only once when the script has finished (having that as a Spyder in-build option rather than writing the code yourself).

anatoly techtonik

unread,
Jun 2, 2013, 2:25:48 AM6/2/13
to spyd...@googlegroups.com
On Monday, May 27, 2013 2:33:42 PM UTC+3, Aeronaelius wrote:
Well, what I want is already possible in a way. Like you said by setting the script to run in its own dedicated interpreter the timer starts when the interpreter is born and stops when the script is finished. However that is only possible IF you do not add the option to interact with the interpreter after the script has finished (as I said before). So basically what could be done is to do the same for when the interaction option is selected.

Another way is to make Spyder print the elapsed time to the console only once when the script has finished (having that as a Spyder in-build option rather than writing the code yourself).

I'd say that would be convenient. I guess the main problem here is to detect if a script is finished with selected interaction option. If I understand it right, the interpreter doesn't signal when script finished and can not detect the phase itself.

Carlos Córdoba

unread,
Jun 9, 2013, 10:20:44 PM6/9/13
to spyd...@googlegroups.com
IPython has a magic called %timeit that does exactly what you need. We could add an option to our Preferences pane to run it by default.

Cheers,
Carlos

El 02/06/13 01:25, anatoly techtonik escribió:
--
You received this message because you are subscribed to the Google Groups "spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spyderlib+...@googlegroups.com.
To post to this group, send email to spyd...@googlegroups.com.
Visit this group at http://groups.google.com/group/spyderlib?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages