Commit | Line | Data |
ddca6c8f |
1 | use strict; |
2 | use warnings; |
3 | use Benchmark qw/cmpthese/; |
4 | use String::TT qw/tt/; |
5 | |
6 | for my $klass (qw/Moose Mouse/) { |
7 | eval tt(q{ |
8 | package [% klass %]One; |
9 | use [% klass %]; |
10 | has n => ( |
11 | is => 'rw', |
12 | isa => 'Int', |
13 | ); |
14 | no [% klass %]; |
15 | __PACKAGE__->meta->make_immutable; |
16 | }); |
17 | die $@ if $@; |
18 | } |
19 | |
dd034272 |
20 | print "Class::MOP: $Class::MOP::VERSION\n"; |
21 | print "Moose: $Moose::VERSION\n"; |
22 | print "Mouse: $Mouse::VERSION\n"; |
ddca6c8f |
23 | print "---- new\n"; |
24 | cmpthese( |
25 | 100000 => { |
26 | map { my $x = $_; $_ => sub { $x->new(n => 3) } } |
27 | map { "${_}One" } |
28 | qw/Moose Mouse/ |
29 | } |
30 | ); |
31 | |
32 | print "---- new,set\n"; |
33 | cmpthese( |
34 | 100000 => { |
35 | map { my $y = $_; $_ => sub { $y->new(n => 3)->n(5) } } |
36 | map { "${_}One" } |
37 | qw/Moose Mouse/ |
38 | } |
39 | ); |
b7e3d8b3 |
40 | |
41 | print "---- set\n"; |
42 | my %c = map { $_ => "${_}One"->new(n => 3) } qw/Moose Mouse/; |
43 | cmpthese( |
44 | 100000 => { |
45 | map { my $y = $_; $_ => sub { $c{$y}->n(5) } } |
46 | qw/Moose Mouse/ |
47 | } |
48 | ); |
49 | |
50 | print "---- get\n"; |
51 | cmpthese( |
52 | 0 => { |
53 | map { my $y = $_; $_ => sub { $c{$y}->n() } } |
54 | qw/Moose Mouse/ |
55 | } |
56 | ); |
57 | |