performance enhancements
[gitmo/Moose.git] / benchmarks / type_constraints.pl
CommitLineData
43123819 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Benchmark qw[cmpthese];
7
8{
9 package Foo;
10 use Moose;
11 use Moose::Util::TypeConstraints;
12
13 has 'baz' => (is => 'rw');
14 has 'bar' => (is => 'rw', isa => 'Foo');
15 has 'boo' => (is => 'rw', isa => type 'CustomFoo' => where { blessed($_) && $_->isa('Foo') });
16}
17
18my $foo = Foo->new;
19
20cmpthese(200_000,
21 {
22 'w/out_constraint' => sub {
23 $foo->baz($foo);
24 },
25 'w_constraint' => sub {
26 $foo->bar($foo);
27 },
28 'w_custom_constraint' => sub {
29 $foo->boo($foo);
30 },
31 }
32);
33
341;