use strict; use warnings; use MCE::Hobo; use Foo::Inbox2; use List::Util qw( shuffle ); use Time::HiRes qw( time ); my @names = shuffle qw/ Barny Betty Fred Wilma /; my $inbox = Foo::Inbox2->new( @names ); my $start = time; $| = 1; sub foo { my $name = shift; my $count = 0; # remove my name from the list @names = grep { $_ ne $name } shuffle @names; # send greeting $inbox->send($name, \@names, 'Hello'); while ( my ($from, $data) = $inbox->recv($name) ) { # display the message received printf "%-5s received %s from %s\n", $name, $data->[0], $from; # send greeting again $inbox->send($name, \@names, 'Hello') if $count < 4167; # eventually stop benchmarking last if ++$count == 12500; } } MCE::Hobo->create(\&foo, $_) for @names; MCE::Hobo->waitall; printf {*STDERR} "duration: %0.03f seconds\n", time - $start;