[lug] Polling a file under linux

Sean Reifschneider jafo at tummy.com
Mon Apr 21 14:04:24 MDT 2003


On Mon, Apr 21, 2003 at 11:57:04AM -0500, Rob Judd wrote:
>1. read the contents of the file before every connection
>2. stat the file before every connection
>
>both of these are rather expensive, especially if connections are made
>several times a second.

I guess it depends on what you mean by "expensive".  On my laptop, it
looks like I can do a stat in a C program in about 1/450,000th of a
second.  In Python this drops down to being about 1/65,000th of a
second.  So, if by "several times a second" you mean several thousand
times a second, I'd agree that stat() may be a bit expensive...

Remember, premature optimization is the root of all evil.  The first
rule of optimization is: Don't do it...

Sean
-- 
 Read error: 666 (Connection reset by Satan)
Sean Reifschneider, Inimitably Superfluous <jafo at tummy.com>
tummy.com, ltd. - Linux Consulting since 1995.  Qmail, Python, SysAdmin
      Back off man. I'm a scientist.   http://HackingSociety.org/



More information about the LUG mailing list