Flash plug-in : CPU salesman ?!
Paul Sladen
ubuntu at paul.sladen.org
Fri May 19 12:42:08 UTC 2006
On Tue, 16 May 2006, Vincent Trouilliez wrote:
> I have just got the Macromedia Flash plug-in working on Dapper. [..]
> For example when viewing this site : www.europe1.fr CPU usage varies
> between around 70% (at best) and shows spikes at 100% !
This depends on how the flash movie is written. For instance there's two
ways of doing animation:
10 Draw new image ("frame")
20 Ask current time.
30 Sleep for until next frame is due (eg. 1/10th second)
40 GOTO 10
or:
10 Ask current time, round to near 1/10th second.
20 Draw new image ("frame")
30 GOTO 10
The second one will end up drawing the same image multiple times, no matter
how fast your CPU is. And the faster your processor is, the more times it
can [re-]draw the same frame before moving on.
This is much the same a programming, where there are two models; "polling"
and "event driven". With polling, you have a very small loop that keeps
checking whether anything has changed (which is what uses up all the CPU),
where-as with event-driven you "yield()" your use of the processor and
make it available to other programs, *until* you get a message telling you
that something has happened.
When the all the processes have yielding (like passing a bowl of sweets
around a circle and everyone saying "no thanks") then the CPU is "idle" and
this allows the processor to go to sleep, or slow down to save heat and
power.
-Paul
--
High on a Spanish mountain, surrounded by howling dogs. Southampton, GB
More information about the ubuntu-users
mailing list