[lug] Polling a file under linux

Ed Hill ed at eh3.com
Mon Apr 21 16:04:50 MDT 2003

On Mon, 2003-04-21 at 14:04, Sean Reifschneider wrote:
> 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...

You give it way too much credit.  Its more like "a root of some evil". 
There are *myriad* ways to botch things and premature optimization is
only one of them.



Edward H. Hill III, PhD 
Post-Doctoral Researcher
Division of ESE, Colorado School of Mines, Golden, CO 80401
Email: ed at eh3.com  ehill at mines.edu
Phone: 303-273-3483
URLs:  http://cesep.mines.edu/people/hill.htm  http://eh3.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.lug.boulder.co.us/pipermail/lug/attachments/20030421/536ed938/attachment.pgp>

More information about the LUG mailing list