Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to debug this

Subject: How to debug this

From: Alex

Date: 14 Nov, 2011 13:32:07

Message: 1 of 2

Dear all,
I will try to explain my problem in an algorithmic fashion and they with your help I will provide more details when is needed I have a program that does the following

fopen in append mode a file
It loops with for for a large number like 500.000
  starts timer
  Read A measurement from an external device
  Writes it in the file opened outside the loop
  stops timer
  print End-Start timer value

End of loop
fclose the file opened.

One think that one can see is that the time goes by the command

print End-Start timer value will start yielding larger and larger values. As an example
for 3 days this will stay constant with a small variation of a few 10ths of milliseconds.
After the third day (actually when the loop counter reaches around 200.000) this start to give larger time drifted values and from the tenths of milliseconds will go up to few seconds drift.

To make it this precise
for the first three day (below 200.000 iteration) there is a drift of 10-20ms
for the fourth and firth day a drift of 1-2seconds
for the sixth and seventh day a drift of 30seconds to 1 minute!!!

MY system has enough free memory and hard disk all these days that the experiment runs.

I have tried to put some tic toc in the code and see the values getting higher but it is really hard to see where this problems happens!

How do you suggest me to try to debug this problem? Would profiler for example will be able to catch the phenomenon that I described above?

I would like to thank you in advance for your help
B.R
Alex

Subject: How to debug this

From: Steven_Lord

Date: 14 Nov, 2011 14:18:52

Message: 2 of 2



"Alex " <alaios@yahoo.com> wrote in message
news:j9r58n$j2f$1@newscl01ah.mathworks.com...
> Dear all,
> I will try to explain my problem in an algorithmic fashion and they with
> your help I will provide more details when is needed I have a program that
> does the following
>
> fopen in append mode a file
> It loops with for for a large number like 500.000
> starts timer
> Read A measurement from an external device
> Writes it in the file opened outside the loop
> stops timer
> print End-Start timer value
>
> End of loop
> fclose the file opened.
>
> One think that one can see is that the time goes by the command
>
> print End-Start timer value will start yielding larger and larger values.
> As an example for 3 days this will stay constant with a small variation of
> a few 10ths of milliseconds.
> After the third day (actually when the loop counter reaches around
> 200.000) this start to give larger time drifted values and from the tenths
> of milliseconds will go up to few seconds drift.
>
> To make it this precise
> for the first three day (below 200.000 iteration) there is a drift of
> 10-20ms
> for the fourth and firth day a drift of 1-2seconds
> for the sixth and seventh day a drift of 30seconds to 1 minute!!!
>
> MY system has enough free memory and hard disk all these days that the
> experiment runs.
>
> I have tried to put some tic toc in the code and see the values getting
> higher but it is really hard to see where this problems happens!
> How do you suggest me to try to debug this problem? Would profiler for
> example will be able to catch the phenomenon that I described above?

Impossible to say without seeing your code, but I'm guessing that either
you're growing a matrix in your loop or the external device is taking longer
and longer to return the desired quantity of data. If you want to make this
less guesswork-based, post a SMALL sample of code to the newsgroup.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

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.

Contact us