projects
/
gitmo/Mouse.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
blame
|
history
|
raw
|
HEAD
Add tests for magical vars and hash iterators
[gitmo/Mouse.git]
/
author
/
benchmarks
/
caf.pl
1
# benchmark
2
use strict;
3
use warnings;
4
use Benchmark ':all';
5
6
{
7
package Bench::CAF;
8
use base 'Class::Accessor::Fast';
9
__PACKAGE__->mk_accessors(qw/a/);
10
}
11
12
{
13
package Bench::Mouse;
14
use Mouse;
15
has 'a' => ( is => 'rw' );
16
no Mouse;
17
__PACKAGE__->meta->make_immutable;
18
}
19
20
my $c = Bench::CAF->new;
21
my $m = Bench::Mouse->new;
22
23
print "-- new\n";
24
cmpthese(
25
-1, {
26
mouse => sub {
27
Bench::Mouse->new()
28
},
29
caf => sub {
30
Bench::CAF->new()
31
},
32
},
33
);
34
35
print "-- setter\n";
36
cmpthese(
37
-1, {
38
mouse => sub {
39
$m->a(1);
40
},
41
caf => sub {
42
$c->a(1)
43
},
44
},
45
);
46
47
print "-- getter\n";
48
cmpthese(
49
-1, {
50
mouse => sub {
51
$m->a;
52
},
53
caf => sub {
54
$c->a
55
},
56
},
57
);
58