]>
Dogcows Code - chaz/p5-CGI-Ex/blob - t/samples/bench_method_calling.pl
4 use Benchmark
qw(cmpthese);
5 use CGI
::Ex
::Dump
qw(debug);
11 use vars
qw($AUTOLOAD);
14 my $meth = ($AUTOLOAD =~ /::(\w+)$/) ? $1 : die "Bad method $AUTOLOAD";
15 die "Unknown property $meth" if ! exists $self->{$meth};
17 $self->{$meth} = shift;
31 * {"B::$prop"} = sub {
34 $self->{$prop} = shift;
36 return $self->{$prop};
39 $self->$prop(@_) if $#_ != -1;
49 my $name = __PACKAGE__
."::". $prop;
50 *$name = sub : lvalue
{
52 $self->{$prop} = shift() if $#_ != -1;
54 } if ! defined &$name;
55 $self->$prop() = shift() if $#_ != -1;
59 my $a = bless {}, 'A';
65 my $b = bless {}, 'B';
66 $b->add_property('foo', 1);
71 my $c = bless {}, 'C';
72 $c->add_property('foo', 1);
77 my $d = bless {}, 'C';
78 $d->add_property('foo', 1);
84 use constant do_set
=> 1;
99 addproperty_withlvalue
=> sub {
105 addproperty_withlvalue2
=> sub {
This page took 0.036469 seconds and 4 git commands to generate.