/usr/share/doc/libanyevent-perl/examples/bench is in libanyevent-perl 6.120-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | #!/usr/bin/perl
# ugly code, don't look at it
# ulimit -n 500000
use strict;
use Event;
use EV;
use Socket;
use AnyEvent;
use Time::HiRes 'time';
my $nr = $ARGV[0] || 1000;
my $M = $ARGV[1] || "AnyEvent";
#$nr *= .01;
my $todo;
my $cv;
my (@io, @timer);
AnyEvent::detect;
my $cb = sub {
$cv->broadcast unless --$todo;
};
$| = 1;
print "name $ARGV[2]\n";
print "watchers ", $nr * 2, "\n";
my $m = qx<ps h -orss $$>;
my $c = time;
my $fh = \*STDOUT;
for (1..$nr) {
if ($M eq "EV") {
push @io, EV::io $fh, EV::WRITE, $cb;
push @timer, EV::timer 0, 0, $cb;
} elsif ($M eq "Event") {
push @io, Event->io (fd => $fh, poll => "w", cb => $cb);
push @timer, Event->timer (after => 0, cb => $cb);
} else {
push @io, AnyEvent->io (fh => $fh, poll => "w", cb => $cb);
push @timer, AnyEvent->timer (after => 0, cb => $cb);
}
}
$c = (time - $c) / $nr / 2 * 1e6;
$m = int 0.5 + (qx<ps h -orss $$> - $m) * 1024 / $nr / 2;
printf "bytes %d\n", $m;
printf "create %.2f\n", $c;
$cv = AnyEvent->condvar;
$todo = $nr * 2;
my $i = time;
$cv->wait;
$i = (time - $i) / $nr / 2 * 1e6;
printf "invoke %.2f\n", $i;
my $d = time;
if ($M eq "Event") {
$_->cancel for (@io, @timer);
}
@io = @timer = ();
{
my $w = AnyEvent->timer (after => 0, cb => sub { });
AnyEvent->one_event;
}
$d = (time - $d) / $nr / 2 * 1e6;
printf "destroy %.2f\n", $d;
|