Just wanted to point out that tic/toc measures wall time, and not cputime. Wall time may be what the original poster want.
If someone can point to a good discussion on how to measure algorithm time (say for scientific publication) I would be interested.
In my C functions (not scripts) I return the timing results. I have found that to be convenient.
Sent from an Android phone running a Linux kernel.
address@hidden wrote:
Send Help-octave mailing list submissions to address@hidden
To subscribe or unsubscribe via the World Wide Web, visit https://mailman.cae.wisc.edu/listinfo/help-octave or, via email, send a message with subject or body 'help' to address@hidden
You can reach the person managing the list at address@hidden
When replying, please edit your Subject line so it is more specific than "Re: Contents of Help-octave digest..."
Message: 1 Date: Sun, 18 Dec 2011 11:53:34 -0500 From: Ben Abbott <address@hidden> To: BVBA NuKey Music <address@hidden> Cc: address@hidden Subject: Re: measuring script speed Message-ID: <address@hidden> Content-Type: text/plain; CHARSET=US-ASCII
On Dec 18, 2011, at 11:49 AM, BVBA NuKey Music wrote:
> I thought I could measure the execution time of a script like this: > begintime=cputime;myscript;cputime-begintime > > this does not work however with scripts which start with a clear > command because the begintime-variable gets erased. Therefore I > thought in stead of deleting the clear statement for the test, I could > proceed as follows: > global begintime=cputime;myscript;cputime-begintime > > unfortunately this doesn't work, I also tried this on the linux command line: > time octave<myscript.m > > this works but I see the octave-environment being opened which could > falsify the timing results > > so what's the best way to achieve this? > > thanks in advance > nukey
Try
tic (); myscript; toc ()
Ben
------------------------------
Message: 2 Date: Sun, 18 Dec 2011 17:59:50 +0100 From: BVBA NuKey Music <address@hidden> To: Ben Abbott <address@hidden>, address@hidden Subject: Re: measuring script speed Message-ID: <address@hidden> Content-Type: text/plain; charset="iso-8859-1"
2011/12/18 Ben Abbott <address@hidden>
> On Dec 18, 2011, at 11:49 AM, BVBA NuKey Music wrote: > > > I thought I could measure the execution time of a script like this: > > begintime=cputime;myscript;cputime-begintime > > > > this does not work however with scripts which start with a clear > > command because the begintime-variable gets erased. Therefore I > > thought in stead of deleting the clear statement for the test, I could > > proceed as follows: > > global begintime=cputime;myscript;cputime-begintime > > > > unfortunately this doesn't work, I also tried this on the linux command > line: > > time octave<myscript.m > > > > this works but I see the octave-environment being opened which could > > falsify the timing results > > > > so what's the best way to achieve this? > > > > thanks in advance > > nukey > > Try > > tic (); myscript; toc () > > Ben > Thanks, this solves my problem!
best regards, nukey -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mailman.cae.wisc.edu/pipermail/help-octave/attachments/20111218/0d547433/attachment-0001.html>
------------------------------
Message: 3 Date: Sun, 18 Dec 2011 18:05:43 +0100 From: marco atzeri <address@hidden> To: address@hidden Subject: Re: measuring script speed Message-ID: <address@hidden> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
On 12/18/2011 5:49 PM, BVBA NuKey Music wrote: > I thought I could measure the execution time of a script like this: > begintime=cputime;myscript;cputime-begintime > > this does not work however with scripts which start with a clear > command because the begintime-variable gets erased. Therefore I > thought in stead of deleting the clear statement for the test, I could > proceed as follows: > global begintime=cputime;myscript;cputime-begintime > > unfortunately this doesn't work, I also tried this on the linux command line: > time octave<myscript.m > > this works but I see the octave-environment being opened which could > falsify the timing results > > so what's the best way to achieve this? > > thanks in advance > nukey
tic() myscript; toc()
Regards Marco
------------------------------
_______________________________________________ Help-octave mailing list address@hidden https://mailman.cae.wisc.edu/listinfo/help-octave
End of Help-octave Digest, Vol 69, Issue 62 *******************************************