Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: IO::Select: select vs. can_read

by MarkM (Curate)
on May 05, 2003 at 13:35 UTC ( [id://255617]=note: print w/replies, xml ) Need Help??


in reply to IO::Select: select vs. can_read

In theory, can_read() is more efficient in cases where you have a large number of clients that remains mostly constant between calls to can_read(), since add() and remove() should be performing only bit operations, wheras IO::Select::select() re-creates the bit mask every time.

In practice, I wouldn't be able to guess which one is faster. Graham Barr (the author of IO::Select) does implement add() and remove() using bit operations, however, he has a lot of rather inefficient code between add(), remove() and the code that actually does the bit operations.

Personally, I make the bit fields myself. The code isn't that complicated, and I handle things that can_read() does not such EINTR. add() is implemented in terms of vec(...) = 1, etc.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://255617]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-19 19:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found