← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/bin/epoll_server.pl
  Run on Wed Jan 5 05:34:33 2011
Reported on Wed Jan 5 05:36:50 2011

File /usr/lib/perl5/vendor_perl/5.10.1/Catalyst/Plugin/I18N.pm
Statements Executed 15607
Statement Execution Time 164ms
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
17254380.7ms4.91sCatalyst::Plugin::I18N::::localizeCatalyst::Plugin::I18N::localize
17355369.1ms4.40sCatalyst::Plugin::I18N::::languagesCatalyst::Plugin::I18N::languages
1115.91ms6.13msCatalyst::Plugin::I18N::::BEGIN@7Catalyst::Plugin::I18N::BEGIN@7
1113.61ms4.50msCatalyst::Plugin::I18N::::BEGIN@8Catalyst::Plugin::I18N::BEGIN@8
111497µs65.9msCatalyst::Plugin::I18N::::setupCatalyst::Plugin::I18N::setup
11141µs88µsCatalyst::Plugin::I18N::::BEGIN@175Catalyst::Plugin::I18N::BEGIN@175
11131µs134µsCatalyst::Plugin::I18N::::BEGIN@121Catalyst::Plugin::I18N::BEGIN@121
11130µs37µsCatalyst::Plugin::I18N::::BEGIN@3Catalyst::Plugin::I18N::BEGIN@3
11120µs24µsCatalyst::Plugin::I18N::::BEGIN@6Catalyst::Plugin::I18N::BEGIN@6
22218µs18µsCatalyst::Plugin::I18N::::CORE:substCatalyst::Plugin::I18N::CORE:subst (opcode)
11117µs52µsCatalyst::Plugin::I18N::::BEGIN@4Catalyst::Plugin::I18N::BEGIN@4
0000s0sCatalyst::Plugin::I18N::::languageCatalyst::Plugin::I18N::language
0000s0sCatalyst::Plugin::I18N::::language_tagCatalyst::Plugin::I18N::language_tag
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Catalyst::Plugin::I18N;
2
3345µs245µs
# spent 37µs (30+8) within Catalyst::Plugin::I18N::BEGIN@3 which was called # once (30µs+8µs) by Class::MOP::__ANON__[/usr/lib/perl5/vendor_perl/5.10.1/i386-linux-thread-multi/Class/MOP.pm:103] at line 3
use strict;
# spent 37µs making 1 call to Catalyst::Plugin::I18N::BEGIN@3 # spent 8µs making 1 call to strict::import
4344µs287µs
# spent 52µs (17+35) within Catalyst::Plugin::I18N::BEGIN@4 which was called # once (17µs+35µs) by Class::MOP::__ANON__[/usr/lib/perl5/vendor_perl/5.10.1/i386-linux-thread-multi/Class/MOP.pm:103] at line 4
use warnings;
# spent 52µs making 1 call to Catalyst::Plugin::I18N::BEGIN@4 # spent 35µs making 1 call to warnings::import
5
6343µs228µs
# spent 24µs (20+4) within Catalyst::Plugin::I18N::BEGIN@6 which was called # once (20µs+4µs) by Class::MOP::__ANON__[/usr/lib/perl5/vendor_perl/5.10.1/i386-linux-thread-multi/Class/MOP.pm:103] at line 6
use MRO::Compat;
# spent 24µs making 1 call to Catalyst::Plugin::I18N::BEGIN@6 # spent 4µs making 1 call to UNIVERSAL::import
73302µs16.13ms
# spent 6.13ms (5.91+214µs) within Catalyst::Plugin::I18N::BEGIN@7 which was called # once (5.91ms+214µs) by Class::MOP::__ANON__[/usr/lib/perl5/vendor_perl/5.10.1/i386-linux-thread-multi/Class/MOP.pm:103] at line 7
use I18N::LangTags ();
# spent 6.13ms making 1 call to Catalyst::Plugin::I18N::BEGIN@7
831.13ms24.51ms
# spent 4.50ms (3.61+893µs) within Catalyst::Plugin::I18N::BEGIN@8 which was called # once (3.61ms+893µs) by Class::MOP::__ANON__[/usr/lib/perl5/vendor_perl/5.10.1/i386-linux-thread-multi/Class/MOP.pm:103] at line 8
use I18N::LangTags::Detect;
# spent 4.50ms making 1 call to Catalyst::Plugin::I18N::BEGIN@8 # spent 8µs making 1 call to UNIVERSAL::import
9
101306µsrequire Locale::Maketext::Simple;
11
1212µsour $VERSION = '0.09';
1317µsour %options = ( Export => '_loc', Decode => 1 );
14
15=head1 NAME
16
17Catalyst::Plugin::I18N - I18N for Catalyst
18
19=head1 SYNOPSIS
20
21 use Catalyst 'I18N';
22
23 print join ' ', @{ $c->languages };
24 $c->languages( ['de'] );
25 print $c->localize('Hello Catalyst');
26
27Use a macro if you're lazy:
28
29 [% MACRO l(text, args) BLOCK;
30 c.localize(text, args);
31 END; %]
32
33 [% l('Hello Catalyst') %]
34 [% l('Hello [_1]', 'Catalyst') %]
35 [% l('lalala[_1]lalala[_2]', ['test', 'foo']) %]
36
37=head1 DESCRIPTION
38
39Supports mo/po files and Maketext classes under your applications I18N
40namespace.
41
42 # MyApp/I18N/de.po
43 msgid "Hello Catalyst"
44 msgstr "Hallo Katalysator"
45
46 #MyApp/I18N/de.pm
47 package MyApp::I18N::de;
48 use base 'MyApp::I18N';
49 our %Lexicon = ( 'Hello Catalyst' => 'Hallo Katalysator' );
50 1;
51
52=head2 CONFIGURATION
53
54You can override any parameter sent to L<Locale::Maketext::Simple> by specifying
55a C<maketext_options> hashref to the C<Plugin::I18N> config section. For
56example, the following configuration will override the C<Decode> parameter which
57normally defaults to C<1>:
58
59 __PACKAGE__->config(
60 'Plugin::I18N' =>
61 maketext_options => {
62 Decode => 0
63 }
64 );
65
66=head2 EXTENDED METHODS
67
68=head3 setup
69
70=cut
71
72
# spent 65.9ms (497µs+65.4) within Catalyst::Plugin::I18N::setup which was called # once (497µs+65.4ms) by Catalyst::Plugin::Session::setup at line 36 of mro.pm
sub setup {
7311250µs my $self = shift;
74 $self->next::method(@_);
# spent 32µs making 1 call to next::method
75 my $calldir = $self;
76 $calldir =~ s{::}{/}g;
# spent 4µs making 1 call to Catalyst::Plugin::I18N::CORE:subst
77 my $file = "$calldir.pm";
78 my $path = $INC{$file};
79 $path =~ s{\.pm$}{/I18N};
# spent 13µs making 1 call to Catalyst::Plugin::I18N::CORE:subst
80
81 my $user_opts = $self->config->{ 'Plugin::I18N' }->{ maketext_options } || {};
# spent 381µs making 1 call to Catalyst::config
82 local %options = ( %options, Path => $path, %$user_opts );
83
84134µs164.5ms eval <<"";
# spent 64.5ms making 1 call to Locale::Maketext::Simple::import
85 package $self;
86 Locale::Maketext::Simple->import( \%Catalyst\::Plugin\::I18N\::options );
87
88
891204µs if ($@) {
90 $self->log->error(qq/Couldn't initialize i18n "$self\::I18N", "$@"/);
91 }
92 else {
93 $self->log->debug(qq/Initialized i18n "$self\::I18N"/) if $self->debug;
# spent 305µs making 1 call to Catalyst::Log::debug # spent 79µs making 1 call to Catalyst::_log_accessor # spent 8µs making 1 call to Epoll::debug
94 }
95}
96
97=head2 METHODS
98
99=head3 languages
100
101Contains languages.
102
103 $c->languages(['de_DE']);
104 print join '', @{ $c->languages };
105
106=cut
107
108
# spent 4.40s (69.1ms+4.34) within Catalyst::Plugin::I18N::languages which was called 1735 times, avg 2.54ms/call: # 1725 times (68.8ms+4.31s) by Catalyst::Plugin::I18N::localize at line 174, avg 2.54ms/call # 3 times (80µs+8.01ms) by Epoll::View::Mail::render at line 51 of Epoll/View/Mail.pm, avg 2.70ms/call # 3 times (119µs+7.71ms) by Epoll::View::Mail::render at line 30 of Epoll/View/Mail.pm, avg 2.61ms/call # 3 times (71µs+5.96ms) by Epoll::View::Mail::render at line 31 of Epoll/View/Mail.pm, avg 2.01ms/call # once (35µs+2.79ms) by Epoll::Controller::Root::begin at line 37 of Epoll/Controller/Root.pm
sub languages {
109694082.1ms my ( $c, $languages ) = @_;
11017284.93ms if ($languages) { $c->{languages} = $languages }
111 else {
112 $c->{languages} ||= [
113 I18N::LangTags::implicate_supers(
114 I18N::LangTags::Detect->http_accept_langs(
115 $c->request->header('Accept-Language')
116 )
117 ),
118 'i-default'
119 ];
120 }
1213981µs2237µs
# spent 134µs (31+103) within Catalyst::Plugin::I18N::BEGIN@121 which was called # once (31µs+103µs) by Class::MOP::__ANON__[/usr/lib/perl5/vendor_perl/5.10.1/i386-linux-thread-multi/Class/MOP.pm:103] at line 121
no strict 'refs';
# spent 134µs making 1 call to Catalyst::Plugin::I18N::BEGIN@121 # spent 103µs making 1 call to strict::unimport
122 &{ ref($c) . '::_loc_lang' }( @{ $c->{languages} } );
# spent 4.34s making 1735 calls to Locale::Maketext::Simple::__ANON__[Locale/Maketext/Simple.pm:197], avg 2.50ms/call
123 return $c->{languages};
124}
125
126=head3 language
127
128return selected locale in your locales list.
129
130=cut
131
132sub language {
133 my $c = shift;
134 my $class = ref $c || $c;
135
136 my $lang = ref "$class\::I18N"->get_handle( @{ $c->languages } );
137 $lang =~ s/.*:://;
138
139 return $lang;
140}
141
142=head3 language_tag
143
144return language tag for current locale. The most notable difference from this
145method in comparison to C<language()> is typically that languages and regions
146are joined with a dash and not an underscore.
147
148 $c->language(); # en_us
149 $c->language_tag(); # en-us
150
151=cut
152
153sub language_tag {
154 my $c = shift;
155 my $class = ref $c || $c;
156
157 return "$class\::I18N"->get_handle( @{ $c->languages } )->language_tag;
158}
159
160=head3 loc
161
162=head3 localize
163
164Localize text.
165
166 print $c->localize( 'Welcome to Catalyst, [_1]', 'sri' );
167
168=cut
169
17016µs*loc = \&localize;
171
172
# spent 4.91s (80.7ms+4.83) within Catalyst::Plugin::I18N::localize which was called 1725 times, avg 2.85ms/call: # 1693 times (79.3ms+4.66s) by Template::Stash::XS::get at line 1 of Epoll/root/templates/includes/loc.tt, avg 2.80ms/call # 27 times (1.21ms+60.0ms) by Template::Stash::XS::get at line 1 of Epoll/root/mail/includes/loc.tt, avg 2.27ms/call # 3 times (68µs+96.3ms) by Epoll::Controller::Admin::voters at line 210 of Epoll/Controller/Admin.pm, avg 32.1ms/call # 2 times (79µs+14.2ms) by Epoll::Controller::Admin::voters at line 228 of Epoll/Controller/Admin.pm, avg 7.13ms/call
sub localize {
173690073.3ms my $c = shift;
174 $c->languages;
# spent 4.38s making 1725 calls to Catalyst::Plugin::I18N::languages, avg 2.54ms/call
1753290µs2134µs
# spent 88µs (41+47) within Catalyst::Plugin::I18N::BEGIN@175 which was called # once (41µs+47µs) by Class::MOP::__ANON__[/usr/lib/perl5/vendor_perl/5.10.1/i386-linux-thread-multi/Class/MOP.pm:103] at line 175
no strict 'refs';
# spent 88µs making 1 call to Catalyst::Plugin::I18N::BEGIN@175 # spent 47µs making 1 call to strict::unimport
176 return &{ ref($c) . '::_loc' }( $_[0], @{ $_[1] } )
177 if ( ref $_[1] eq 'ARRAY' );
178 return &{ ref($c) . '::_loc' }(@_);
# spent 453ms making 1725 calls to Locale::Maketext::Simple::__ANON__[Locale/Maketext/Simple.pm:167], avg 262µs/call
179}
180
181=head1 SEE ALSO
182
183L<Catalyst>
184
185=head1 AUTHOR
186
187Sebastian Riedel E<lt>sri@cpan.orgE<gt>
188
189Brian Cassidy E<lt>bricas@cpan.orgE<gt>
190
191Christian Hansen E<lt>chansen@cpan.orgE<gt>
192
193=head1 COPYRIGHT AND LICENSE
194
195This program is free software, you can redistribute it and/or modify it under
196the same terms as Perl itself.
197
198=cut
199
200114µs1;
# spent 18µs within Catalyst::Plugin::I18N::CORE:subst which was called 2 times, avg 9µs/call: # once (13µs+0s) by Catalyst::Plugin::I18N::setup at line 79 of Catalyst/Plugin/I18N.pm # once (4µs+0s) by Catalyst::Plugin::I18N::setup at line 76 of Catalyst/Plugin/I18N.pm
sub Catalyst::Plugin::I18N::CORE:subst; # xsub