Thread Subject: strange timing results in the profiler

Subject: strange timing results in the profiler

From: Michael Sprung

Date: 7 Sep, 2006 16:01:34

Message: 1 of 3

Hello:

I'm trying to use the profiler to look for bottle necks in my code.
However, I get strange timing results.
E.g. here are three lines from the profiler. The numbers are:
time in second, number of calls line number followed by the line of
code

  0.03 1200 102
fseek(fid,imageStart,'bof');
 9202860509.29 1200 103
header = cell(47,2) ;
      
  0.31 1200 104
header(1,:) = {'magic',fread(fid,1 ,'int')};

Obviously, the second timing result is wrong. Does anybody know how
to solve this problem? I'm using Matlab R2006a under Windows XP (up
to date) with a Centrino Duo processor.

Help would be greatly appreciated.

Michael

Subject: strange timing results in the profiler

From: Bill Nell

Date: 8 Sep, 2006 13:02:40

Message: 2 of 3

Michael Sprung wrote:
> Hello:
>
> I'm trying to use the profiler to look for bottle necks in my code.
> However, I get strange timing results.
> E.g. here are three lines from the profiler. The numbers are:
> time in second, number of calls line number followed by the line of
> code
>
> 0.03 1200 102
> fseek(fid,imageStart,'bof');
> 9202860509.29 1200 103
> header = cell(47,2) ;
>
> 0.31 1200 104
> header(1,:) = {'magic',fread(fid,1 ,'int')};
>
> Obviously, the second timing result is wrong. Does anybody know how
> to solve this problem? I'm using Matlab R2006a under Windows XP (up
> to date) with a Centrino Duo processor.
>
> Help would be greatly appreciated.
>
> Michael

Hi Michael,

The short answer is to try "profile -timer real" before doing any
profiling. This should fix the problem.

The long answer is that by default the profiler uses the CPU's time
stamp counter to measure time. Certain dual core machines have issues
keeping the time stamp counters between both cores synchronized (usually
on laptops with power saving features enabled). When the time stamp
counters get out of sync the profiler can get very screwy results. So,
the profiler can be switched over to querying the CPU time from the
operating system which is slightly slower and has a lower granularity
than the cycle counters but this shouldn't matter too much.

Hope this helps,
Bill

Subject: strange timing results in the profiler

From: Michael Sprung

Date: 13 Sep, 2006 18:18:57

Message: 3 of 3

Thank you Bill:

This helped! :-)

Michael

Btw: Does someone know if I can make 'profile -timer real' a default
option on this computer?

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

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com