From: <Mar...@t-...> - 2004-01-14 12:21:53
|
On Wed, 14 Jan 2004 11:05:59 +0100 Michael Reinelt <re...@eu...> wrote: > [hashes] > Sorry. Marksu, are you listening? Are you subscribed to lcd4linux-devel? Yes. > The reason for hashes is the following: > > Say you write a plugin which returns values from /proc/cpuinfo. There > are values like "CPU MHz" or "BogoMips". You get these values by reading > and parsing /proc/cpuinfo. > > Now if the plugin is asked for "MHz", it doesn't know that a few > microseconds later a call for "BogoMips" will happen. Therefore for > every call, the whole file would be parsed. > > If you use a hash, you fill up the hash with all values from > /proc/cpuinfo when parsing it. Subsequent calls would not parse the file > again, but read the values from the hash. > > You have to use something like a "timeout", and remember the time when > the contents of the file was last read. If the timeout is over, you have > to read and parse the file again. > > SOme file change very seldom (/proc/cpuinfo probably changes never), > others change quite regular. But you can save a lot of CPU if you define > a timeout of, say, 100 msec. > Great Michael! I will check out the CVS today. Maybe that tommorow the XMMS-Plugin will use the HASH Function. I will work on it. Markus Keil ------ Saxony, Germany |