Profile of /usr/local/lib/perl5/site_perl/5.10.1/MooseX/AttributeHelpers/String.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For 05.Domain_and_Item.t
Run on Tue May 4 17:21:41 2010
Reported on Tue May 4 17:23:18 2010

File | /usr/local/lib/perl5/site_perl/5.10.1/MooseX/AttributeHelpers/String.pm
Statements Executed | 12
Statement Execution Time | 156µs

Subroutines — ordered by exclusive time
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 18µs | 2.17ms | MooseX::AttributeHelpers::String::::BEGIN@3 MooseX::AttributeHelpers::String::BEGIN@3
1 | 1 | 1 | 8µs | 95µs | MooseX::AttributeHelpers::String::::BEGIN@12 MooseX::AttributeHelpers::String::BEGIN@12
0 | 0 | 0 | 0s | 0s | Moose::Meta::Attribute::Custom::String::::register_implementationMoose::Meta::Attribute::Custom::String::register_implementation

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  |
2 |  |  |  |  | package MooseX::AttributeHelpers::String;
3 | 3 | 63µs | 2 | 4.32ms | # spent 2.17ms (18µs+2.15) within MooseX::AttributeHelpers::String::BEGIN@3 which was called # once (18µs+2.15ms) by MooseX::AttributeHelpers::BEGIN@25 at line 3 use Moose; # spent 2.17ms making 1 call to MooseX::AttributeHelpers::String::BEGIN@3 # spent 2.15ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:389]
4 |  |  |  |  |
5 | 1 | 600ns |  |  | our $VERSION = '0.23';
6 | 1 | 14µs |  |  | $VERSION = eval $VERSION;
7 | 1 | 300ns |  |  | our $AUTHORITY = 'cpan:STEVAN';
8 |  |  |  |  |
9 | 1 | 2µs | 1 | 361µs | extends 'Moose::Meta::Attribute'; # spent 361µs making 1 call to Moose::extends
10 | 1 | 1µs | 1 | 8.14ms | with 'MooseX::AttributeHelpers::Trait::String'; # spent 8.14ms making 1 call to Moose::with
11 |  |  |  |  |
12 | 3 | 59µs | 2 | 182µs | # spent 95µs (8+87) within MooseX::AttributeHelpers::String::BEGIN@12 which was called # once (8µs+87µs) by MooseX::AttributeHelpers::BEGIN@25 at line 12 no Moose; # spent 95µs making 1 call to MooseX::AttributeHelpers::String::BEGIN@12 # spent 87µs making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:478]
13 |  |  |  |  |
14 |  |  |  |  | # register the alias ...
15 |  |  |  |  | package # hide me from search.cpan.org
16 |  |  |  |  | Moose::Meta::Attribute::Custom::String;
17 |  |  |  |  | sub register_implementation { 'MooseX::AttributeHelpers::String' }
18 |  |  |  |  |
19 | 1 | 16µs |  |  | 1;
20 |  |  |  |  |
21 |  |  |  |  | __END__
22 |  |  |  |  |
23 |  |  |  |  | =pod
24 |  |  |  |  |
25 |  |  |  |  | =head1 NAME
26 |  |  |  |  |
27 |  |  |  |  | MooseX::AttributeHelpers::String
28 |  |  |  |  |
29 |  |  |  |  | =head1 SYNOPSIS
30 |  |  |  |  |
31 |  |  |  |  | package MyHomePage;
32 |  |  |  |  | use Moose;
33 |  |  |  |  | use MooseX::AttributeHelpers;
34 |  |  |  |  |
35 |  |  |  |  | has 'text' => (
36 |  |  |  |  | metaclass => 'String',
37 |  |  |  |  | is => 'rw',
38 |  |  |  |  | isa => 'Str',
39 |  |  |  |  | default => sub { '' },
40 |  |  |  |  | provides => {
41 |  |  |  |  | append => "add_text",
42 |  |  |  |  | replace => "replace_text",
43 |  |  |  |  | }
44 |  |  |  |  | );
45 |  |  |  |  |
46 |  |  |  |  | my $page = MyHomePage->new();
47 |  |  |  |  | $page->add_text("foo"); # same as $page->text($page->text . "foo");
48 |  |  |  |  |
49 |  |  |  |  | =head1 DESCRIPTION
50 |  |  |  |  |
51 |  |  |  |  | This module provides a simple string attribute, to which mutating string
52 |  |  |  |  | operations can be applied more easily (no need to make an lvalue attribute
53 |  |  |  |  | metaclass or use temporary variables). Additional methods are provided for
54 |  |  |  |  | completion.
55 |  |  |  |  |
56 |  |  |  |  | If your attribute definition does not include any of I<is>, I<isa>,
57 |  |  |  |  | I<default> or I<provides> but does use the C<String> metaclass,
58 |  |  |  |  | then this module applies defaults as in the L</SYNOPSIS>
59 |  |  |  |  | above. This allows for a very basic counter definition:
60 |  |  |  |  |
61 |  |  |  |  | has 'foo' => (metaclass => 'String');
62 |  |  |  |  | $obj->append_foo;
63 |  |  |  |  |
64 |  |  |  |  | =head1 METHODS
65 |  |  |  |  |
66 |  |  |  |  | =over 4
67 |  |  |  |  |
68 |  |  |  |  | =item B<meta>
69 |  |  |  |  |
70 |  |  |  |  | =item B<method_provider>
71 |  |  |  |  |
72 |  |  |  |  | =item B<has_method_provider>
73 |  |  |  |  |
74 |  |  |  |  | =item B<helper_type>
75 |  |  |  |  |
76 |  |  |  |  | =item B<process_options_for_provides>
77 |  |  |  |  |
78 |  |  |  |  | Run before its superclass method.
79 |  |  |  |  |
80 |  |  |  |  | =item B<check_provides_values>
81 |  |  |  |  |
82 |  |  |  |  | Run after its superclass method.
83 |  |  |  |  |
84 |  |  |  |  | =back
85 |  |  |  |  |
86 |  |  |  |  | =head1 PROVIDED METHODS
87 |  |  |  |  |
88 |  |  |  |  | It is important to note that all those methods do in place
89 |  |  |  |  | modification of the value stored in the attribute.
90 |  |  |  |  |
91 |  |  |  |  | =over 4
92 |  |  |  |  |
93 |  |  |  |  | =item I<inc>
94 |  |  |  |  |
95 |  |  |  |  | Increments the value stored in this slot using the magical string autoincrement
96 |  |  |  |  | operator. Note that Perl doesn't provide analogeous behavior in C<-->, so
97 |  |  |  |  | C<dec> is not available.
98 |  |  |  |  |
99 |  |  |  |  | =item I<append> C<$string>
100 |  |  |  |  |
101 |  |  |  |  | Append a string, like C<.=>.
102 |  |  |  |  |
103 |  |  |  |  | =item I<prepend> C<$string>
104 |  |  |  |  |
105 |  |  |  |  | Prepend a string.
106 |  |  |  |  |
107 |  |  |  |  | =item I<replace> C<$pattern> C<$replacement>
108 |  |  |  |  |
109 |  |  |  |  | Performs a regexp substitution (L<perlop/s>). There is no way to provide the
110 |  |  |  |  | C<g> flag, but code references will be accepted for the replacement, causing
111 |  |  |  |  | the regex to be modified with a single C<e>. C</smxi> can be applied using the
112 |  |  |  |  | C<qr> operator.
113 |  |  |  |  |
114 |  |  |  |  | =item I<match> C<$pattern>
115 |  |  |  |  |
116 |  |  |  |  | Like I<replace> but without the replacement. Provided mostly for completeness.
117 |  |  |  |  |
118 |  |  |  |  | =item C<chop>
119 |  |  |  |  |
120 |  |  |  |  | L<perlfunc/chop>
121 |  |  |  |  |
122 |  |  |  |  | =item C<chomp>
123 |  |  |  |  |
124 |  |  |  |  | L<perlfunc/chomp>
125 |  |  |  |  |
126 |  |  |  |  | =item C<clear>
127 |  |  |  |  |
128 |  |  |  |  | Sets the string to the empty string (not the value passed to C<default>).
129 |  |  |  |  |
130 |  |  |  |  | =back
131 |  |  |  |  |
132 |  |  |  |  | =head1 BUGS
133 |  |  |  |  |
134 |  |  |  |  | All complex software has bugs lurking in it, and this module is no
135 |  |  |  |  | exception. If you find a bug please either email me, or add the bug
136 |  |  |  |  | to cpan-RT.
137 |  |  |  |  |
138 |  |  |  |  | =head1 AUTHOR
139 |  |  |  |  |
140 |  |  |  |  | Stevan Little E<lt>stevan@iinteractive.comE<gt>
141 |  |  |  |  |
142 |  |  |  |  | =head1 COPYRIGHT AND LICENSE
143 |  |  |  |  |
144 |  |  |  |  | Copyright 2007-2009 by Infinity Interactive, Inc.
145 |  |  |  |  |
146 |  |  |  |  | L<http://www.iinteractive.com>
147 |  |  |  |  |
148 |  |  |  |  | This library is free software; you can redistribute it and/or modify
149 |  |  |  |  | it under the same terms as Perl itself.
150 |  |  |  |  |
151 |  |  |  |  | =cut