472,103 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,103 software developers and data experts.

Timing a python program run

Hi,

In matlab, I'd calculate the time for a script named test.m to run
with:
>tic, run, toc
Is there some way to do this in python on a mac os x from the terminal
window? Or whatever?

Jul 7 '07 #1
3 1594
David <dw********@suddenlink.netwrote:
Is there some way to do this in python on a mac os x from the terminal
window? Or whatever?
You can use:

% time script.py

from the command line of the terminal

--
Lawrence, oluyede.org - neropercaso.it
"It is difficult to get a man to understand
something when his salary depends on not
understanding it" - Upton Sinclair
Jul 7 '07 #2
On Jul 8, 12:21 am, David <dwarnol...@suddenlink.netwrote:
Hi,

In matlab, I'd calculate the time for a script named test.m to run
with:
tic, run, toc

Is there some way to do this in python on a mac os x from the terminal
window? Or whatever?
The timeit module may be of use:
http://docs.python.org/lib/module-timeit.html

Jul 8 '07 #3
simplest way is just put a timer on start and another on the end,
then calc the elapse. You can also take a look timeit module too
which provides similar but more powerful functions...

-Jim

On Jul 7, 2007, at 12:21 PM, David wrote:
Hi,

In matlab, I'd calculate the time for a script named test.m to run
with:
>>tic, run, toc

Is there some way to do this in python on a mac os x from the terminal
window? Or whatever?

--
http://mail.python.org/mailman/listinfo/python-list
Jul 8 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by S. David Rose | last post: by
1 post views Thread by D. Shifflett | last post: by
19 posts views Thread by John Keeling | last post: by
1 post views Thread by Andreas Lobinger | last post: by
10 posts views Thread by WIdgeteye | last post: by
2 posts views Thread by Oeyvind Brandtsegg | last post: by
2 posts views Thread by Steven D'Aprano | last post: by
15 posts views Thread by Jay | last post: by
5 posts views Thread by John Fisher | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.