Thread Subject:
accuracy of tic-toc functions

Subject: accuracy of tic-toc functions

From: Dario

Date: 9 Apr, 2001 14:38:35

Message: 1 of 6

Hi,
does anyone know what's the accuracy of tic-toc functions?
Is there a better way to measure Matlab execution time?

best regards

dario

Subject: accuracy of tic-toc functions

From: Nabeel

Date: 11 Apr, 2001 13:31:38

Message: 2 of 6

Hi,

The accuracy of the timing functions is about .05 seconds, I believe.
Rather than rely on absolute time, however, I'd suggest looking at
percent times spent in different areas of your code; this is the kind of
information the PROFILE function gives you.

In any case, TIC and TOC give wall-clock time. I prefer to use CPUTIME
to measure execution performance.

-- Nabeel


Dario wrote:
>
> Hi,
> does anyone know what's the accuracy of tic-toc functions?
> Is there a better way to measure Matlab execution time?
>
> best regards
>
> dario

Subject: accuracy of tic-toc functions

From: Jason Bowman

Date: 11 Apr, 2001 17:54:59

Message: 3 of 6

Like Nabeel, I use CPUTIME. But be careful. For example:

>> t = cputime;
>> cputime-t

works but

>> cputime - t

doesn't. The "- t" gets passed to CPUTIME as arguments much like
"filename" gets passed to LOAD below.

>> load filename

The fixed is to put parenthesis around CPUTIME or not put any spaces
between CPUTIME and the trailing operator.

Jason

Dario wrote:
>
> Hi,
> does anyone know what's the accuracy of tic-toc functions?
> Is there a better way to measure Matlab execution time?
>
> best regards
>
> dario

Subject: accuracy of tic-toc functions

From: Nabeel

Date: 11 Apr, 2001 20:12:26

Message: 4 of 6

Hi,

Jason Bowman wrote:
>
> Like Nabeel, I use CPUTIME. But be careful. For example:
>
> >> t = cputime;
> >> cputime-t
>
> works but
>
> >> cputime - t
>
> doesn't. The "- t" gets passed to CPUTIME as arguments much like
> "filename" gets passed to LOAD below.
>
> >> load filename
>
> The fixed is to put parenthesis around CPUTIME or not put any spaces
> between CPUTIME and the trailing operator.


If you're storing the elapsed time in a variable, this won't be an
issue. The command form:

>> load filename

can't produce an output, but the functional form:

>> load('filename')

can. For example:

>> clear all
>> s = load mydata
??? s = load mydata
             |
Error: Missing operator, comma, or semicolon.

>> s = load('mydata')
s =
    x: [1x1 sym]
    f: [1x1 sym]


If you are assigning the output of "cputime - t" to a variable, MATLAB
will see that you're trying to use the functional form and not the
command form, so any spaces that you might have won't be an issue:

>> t = cputime;
>> cputime - t
??? Error using ==> cputime
Too many input arguments.

>> t_elapsed = cputime - t
t_elapsed =
   11.3260

thought you might find this interesting,

-- Nabeel


"I think, therefore I .m"

Subject: accuracy of tic-toc functions

From: loren@mathworks.com (Loren Shure)

Date: 16 Apr, 2001 10:32:08

Message: 5 of 6

In article <9b1fro$5o183@bigarea.area.ba.cnr.it>, ddario@tiscalinet.it
says...
> Hi,
> does anyone know what's the accuracy of tic-toc functions?
> Is there a better way to measure Matlab execution time?
>
> best regards
>
> dario
>
>
>
>

Depending on your purpose, you might want to use the PROFILE command.

--Loren

Subject: accuracy of tic-toc functions

From: Barry D. Jacobson

Date: 16 May, 2001 02:11:04

Message: 6 of 6

Just saw this old thread. I think the .05 second limitation comes from
the hardware clock of PCs which runs at about 18 Hz. However, I think
there are software methods for getting more finely divided time
intervals, but these need to be calibrated against hardware clock when
absolute (as opposed to elapsed) time is required.

Barry

Nabeel <nabeel@mathworks.com> wrote in message
news:3AD494FA.28F951A3@mathworks.com...
> Hi,
>
> The accuracy of the timing functions is about .05 seconds, I believe.
> Rather than rely on absolute time, however, I'd suggest looking at
> percent times spent in different areas of your code; this is the kind
of
> information the PROFILE function gives you.
>
> In any case, TIC and TOC give wall-clock time. I prefer to use
CPUTIME
> to measure execution performance.
>
> -- Nabeel
>
>
> Dario wrote:
> >
> > Hi,
> > does anyone know what's the accuracy of tic-toc functions?
> > Is there a better way to measure Matlab execution time?
> >
> > best regards
> >
> > dario

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us