← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/local/src/github.com/foswiki/core/bin/view
  Run on Sun Dec 4 17:17:59 2011
Reported on Sun Dec 4 17:27:17 2011

Filename/usr/local/src/github.com/foswiki/core/lib/Foswiki/Macros/MAKETEXT.pm
StatementsExecuted 898 statements in 4.84ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
52113.55ms10.9msFoswiki::::MAKETEXTFoswiki::MAKETEXT
11130µs72µsFoswiki::::BEGIN@4.23Foswiki::BEGIN@4.23
11122µs45µsFoswiki::::BEGIN@5.24Foswiki::BEGIN@5.24
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# See bottom of file for license and copyright information
2package Foswiki;
3
4254µs2113µs
# spent 72µs (30+41) within Foswiki::BEGIN@4.23 which was called: # once (30µs+41µs) by Foswiki::_expandMacroOnTopicRendering at line 4
use strict;
# spent 72µs making 1 call to Foswiki::BEGIN@4.23 # spent 41µs making 1 call to strict::import
52485µs268µs
# spent 45µs (22+23) within Foswiki::BEGIN@5.24 which was called: # once (22µs+23µs) by Foswiki::_expandMacroOnTopicRendering at line 5
use warnings;
# spent 45µs making 1 call to Foswiki::BEGIN@5.24 # spent 23µs making 1 call to warnings::import
6
7
# spent 10.9ms (3.55+7.30) within Foswiki::MAKETEXT which was called 52 times, avg 209µs/call: # 52 times (3.55ms+7.30ms) by Foswiki::_expandMacroOnTopicRendering at line 3066 of /usr/local/src/github.com/foswiki/core/lib/Foswiki.pm, avg 209µs/call
sub MAKETEXT {
85298µs my ( $this, $params ) = @_;
9
1052123µs my $str = $params->{_DEFAULT} || $params->{string} || "";
115264µs return "" unless $str;
12
13 # escape everything:
1452361µs52118µs $str =~ s/\[/~[/g;
# spent 118µs making 52 calls to Foswiki::CORE:subst, avg 2µs/call
1552302µs5290µs $str =~ s/\]/~]/g;
# spent 90µs making 52 calls to Foswiki::CORE:subst, avg 2µs/call
16
17 # restore already escaped stuff:
1852271µs5278µs $str =~ s/~~\[/~[/g;
# spent 78µs making 52 calls to Foswiki::CORE:subst, avg 2µs/call
1952259µs5271µs $str =~ s/~~\]/~]/g;
# spent 71µs making 52 calls to Foswiki::CORE:subst, avg 1µs/call
20
21 # unescape parameters and calculate highest parameter number:
225271µs my $max = 0;
2360395µs60128µs $str =~ s/~\[(\_(\d+))~\]/ $max = $2 if ($2 > $max); "[$1]"/ge;
# spent 110µs making 52 calls to Foswiki::CORE:subst, avg 2µs/call # spent 18µs making 8 calls to Foswiki::CORE:substcont, avg 2µs/call
24 $str =~
2552270µs5277µss/~\[(\*,\_(\d+),[^,]+(,([^,]+))?)~\]/ $max = $2 if ($2 > $max); "[$1]"/ge;
# spent 77µs making 52 calls to Foswiki::CORE:subst, avg 1µs/call
26
27 # get the args to be interpolated.
2852105µs my $argsStr = $params->{args} || "";
29
3052124µs my @args = split( /\s*,\s*/, $argsStr );
31
32 # fill omitted args with empty strings
3352175µs while ( ( scalar @args ) < $max ) {
3414µs push( @args, '' );
35 }
36
37 # do the magic:
3852610µs1046.49ms my $result = $this->i18n->maketext( $str, @args );
# spent 5.01ms making 52 calls to Foswiki::i18n, avg 96µs/call # spent 1.48ms making 52 calls to Foswiki::I18N::Fallback::maketext, avg 28µs/call
39
40 # replace accesskeys:
4152485µs74177µs $result =~
# spent 124µs making 52 calls to Foswiki::CORE:subst, avg 2µs/call # spent 53µs making 22 calls to Foswiki::CORE:substcont, avg 2µs/call
42 s#(^|[^&])&([a-zA-Z])#$1<span class='foswikiAccessKey'>$2</span>#g;
43
44 # replace escaped amperstands:
4552265µs5278µs $result =~ s/&&/\&/g;
# spent 78µs making 52 calls to Foswiki::CORE:subst, avg 1µs/call
46
4752313µs return $result;
48}
49
5015µs1;
51__END__