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:
why does "doing nothing" consume so much CPU?

Subject: why does "doing nothing" consume so much CPU?

From: Bruce Bowler

Date: 30 Apr, 2009 18:01:47

Message: 1 of 5

I'm running 2006a on a fedora 9 system. I have the following m file
that, when run, consumes about 15% of the CPU.

function sleep4(snoozeTime)
if (snoozeTime > 0)
    t=timer('timerfcn','sleep4(0)','StartDelay',snoozeTime);
    start(t); wait(t);
end

Why (and is there a better way to "do nothing" for some period of time).



--
+-------------------+---------------------------------------------------+
Bruce Bowler | It's not a sin to be rich anymore it's a miracle.
1.207.633.9600 | - John Connally
bbowler@bigelow.org |
+-------------------+---------------------------------------------------+

Subject: why does "doing nothing" consume so much CPU?

From: vgood

Date: 30 Apr, 2009 18:53:00

Message: 2 of 5

Bruce Bowler <bbowler@bigelow.org> wrote in message <75u7cbF19h2ujU1@mid.individual.net>...
> I'm running 2006a on a fedora 9 system. I have the following m file
> that, when run, consumes about 15% of the CPU.
>
> function sleep4(snoozeTime)
> if (snoozeTime > 0)
> t=timer('timerfcn','sleep4(0)','StartDelay',snoozeTime);
> start(t); wait(t);
> end
>
> Why (and is there a better way to "do nothing" for some period of time).
>
>
>
> --
> +-------------------+---------------------------------------------------+
> Bruce Bowler | It's not a sin to be rich anymore it's a miracle.
> 1.207.633.9600 | - John Connally
> bbowler@bigelow.org |
> +-------------------+---------------------------------------------------+

Bruce,

There just isn't a real "do nothing" mode that I can think of. Even pause is going to consume some CPU time but it might be less overhead than your timer object. I'll give it a quick test if my ML can ever access the license server lol.

Subject: why does "doing nothing" consume so much CPU?

From: James_F Falco

Date: 30 Apr, 2009 18:54:02

Message: 3 of 5


> is there a better way to "do nothing" for some period of time
help pause

Subject: why does "doing nothing" consume so much CPU?

From: vgood

Date: 30 Apr, 2009 18:54:02

Message: 4 of 5

Bruce Bowler <bbowler@bigelow.org> wrote in message <75u7cbF19h2ujU1@mid.individual.net>...
> I'm running 2006a on a fedora 9 system. I have the following m file
> that, when run, consumes about 15% of the CPU.
>
> function sleep4(snoozeTime)
> if (snoozeTime > 0)
> t=timer('timerfcn','sleep4(0)','StartDelay',snoozeTime);
> start(t); wait(t);
> end
>
> Why (and is there a better way to "do nothing" for some period of time).
>
>
>
> --
> +-------------------+---------------------------------------------------+
> Bruce Bowler | It's not a sin to be rich anymore it's a miracle.
> 1.207.633.9600 | - John Connally
> bbowler@bigelow.org |
> +-------------------+---------------------------------------------------+

Bruce,

There just isn't a real "do nothing" mode that I can think of. Even pause is going to consume some CPU time but it might be less overhead than your timer object. I'll give it a quick test if my ML can ever access the license server lol.

Subject: why does "doing nothing" consume so much CPU?

From: Bruce Bowler

Date: 30 Apr, 2009 20:16:13

Message: 5 of 5

On Thu, 30 Apr 2009 18:54:02 +0000, James_F Falco wrote:

>> is there a better way to "do nothing" for some period of time
> help pause

Well, I'd looked at that but not closely enough (my bad, sorry for
wasting peoples time). I saw the reference to keyboard input and missed
the (n). Since this is needed in a "non-interactive" environment, I
dismissed it as a non-starter.

Regarding vgoods idea to test, save your time. I just ran the test here
and a 60 second run of my timer consumes about 15% (as stated earlier),
pause, on the other hand, only about 3%. Sounds like we have a winner...

Bruce


--
+-------------------+---------------------------------------------------+
Bruce Bowler | How can you be two places at once when you're not
1.207.633.9600 | anywhere at all. - Firesign Theater
bbowler@bigelow.org |
+-------------------+---------------------------------------------------+

Tags for this Thread

No tags are associated with 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