#!perl
package
foo;
use
common::sense;
sub
new {
my
$this
=
shift
;
my
$class
=
ref
(
$this
) ||
$this
;
$class
->SUPER::new (
@_
);
}
our
$cnt
;
sub
test : event_cb {
$cnt
++ }
package
main;
use
common::sense;
my
$f
= foo->new;
for
(1..10) {
$f
->reg_cb (
test
=>
sub
{
my
(
$f
) =
@_
;
$foo::cnt
++;
});
}
my
$ev
;
timethese (250000, {
simple
=>
sub
{
$f
->event (
'test'
) },
method
=>
sub
{
$f
->test }
});
"$foo::cnt\n"
;