Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re^4: A question of fork efficiency

by trippledubs (Deacon)
on Aug 07, 2019 at 13:02 UTC ( #11104093=note: print w/replies, xml ) Need Help??

in reply to Re^3: A question of fork efficiency
in thread A question of fork efficiency

Nice! I/O Multiplexed has 4,000 system calls compared to 45,000 with fork measured by strace. Surprised that fork doesn't get smoked in wall clock time. Love the ternary in the if statement, educative as usual.

Replies are listed 'Best First'.
Re^5: A question of fork efficiency
by holli (Abbot) on Aug 07, 2019 at 13:57 UTC
    elsif( @ips ? $sel->count >= $max : $sel->count )
    What you call educative I call overly clever and in this case outright obstructive. This is the equivalent when you get rid of the ternary
    elsif( ( @ips && $sel->count >= $max ) || $sel->count )
    Which is clearer and not even longer. And once you see it like this and realize @ips is not used in within the following block, it becomes apparent you can safely omit that and the conditional becomes
    elsif( $sel->count )
    One should keep conditionals as simple as possible. Similarly is this
    my @connects; for my $fh ( @connects = $sel->can_write($timeout) )
    suboptimal. Apart from, again, obstructing the conditional, one should keep declaration and initialization as close to one another as possible.
    my @connects = $sel->can_write($timeout); for my $fh ( @connects )
    This is better.


    You can lead your users to water, but alas, you cannot drown them.

      Agreed. This is clearer. There are still other issues I have found as far as purposely testing against DNS names you know don't exist. Some of those go to the void and get no output returned.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2020-10-29 01:14 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (265 votes). Check out past polls.