← Index
NYTProf Performance Profile   « line view »
For ./view
  Run on Fri Jul 31 19:05:14 2015
Reported on Fri Jul 31 19:08:10 2015

Filename/var/www/foswiki11/lib/Foswiki/Macros/MAKETEXT.pm
StatementsExecuted 725 statements in 1.92ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1117.84ms15.5msFoswiki::::BEGIN@7Foswiki::BEGIN@7
3311800µs5.63msFoswiki::::MAKETEXTFoswiki::MAKETEXT
41144µs44µsFoswiki::::_validateFoswiki::_validate
11138µs102µsFoswiki::::BEGIN@4Foswiki::BEGIN@4
11130µs58µsFoswiki::::BEGIN@5.39Foswiki::BEGIN@5.39
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
4278µs2166µs
# spent 102µs (38+64) within Foswiki::BEGIN@4 which was called: # once (38µs+64µs) by Foswiki::_expandMacroOnTopicRendering at line 4
use strict;
# spent 102µs making 1 call to Foswiki::BEGIN@4 # spent 64µs making 1 call to strict::import
5270µs284µs
# spent 58µs (30+27) within Foswiki::BEGIN@5.39 which was called: # once (30µs+27µs) by Foswiki::_expandMacroOnTopicRendering at line 5
use warnings;
# spent 58µs making 1 call to Foswiki::BEGIN@5.39 # spent 27µs making 1 call to warnings::import
6
72984µs115.5ms
# spent 15.5ms (7.84+7.61) within Foswiki::BEGIN@7 which was called: # once (7.84ms+7.61ms) by Foswiki::_expandMacroOnTopicRendering at line 7
use Locale::Maketext;
# spent 15.5ms making 1 call to Foswiki::BEGIN@7
8
9
# spent 5.63ms (800µs+4.83) within Foswiki::MAKETEXT which was called 33 times, avg 171µs/call: # 33 times (800µs+4.83ms) by Foswiki::_expandMacroOnTopicRendering at line 3160 of /var/www/foswiki11/lib/Foswiki.pm, avg 171µs/call
sub MAKETEXT {
103323µs my ( $this, $params ) = @_;
11
123335µs my $str = $params->{_DEFAULT} || $params->{string} || "";
13337µs return "" unless $str;
14
15 # escape everything:
163338µs $str =~ s/\[/~[/g;
173322µs $str =~ s/\]/~]/g;
18
19 # restore already escaped stuff:
203317µs $str =~ s/~~+\[/~[/g;
213313µs $str =~ s/~~+\]/~]/g;
22
233314µs my $max = 0;
24339µs my $min = 1;
25339µs my $param_error = 0;
26
27 # unescape parameters and calculate highest parameter number:
283754µs444µs $str =~ s/~\[(\_(\d+))~\]/_validate($1, $2, $max, $min, $param_error)/ge;
# spent 44µs making 4 calls to Foswiki::_validate, avg 11µs/call
29 $str =~
303315µss/~\[(\*,\_(\d+),[^,]+(,([^,]+))?)~\]/ _validate($1, $2, $max, $min, $param_error)/ge;
31338µs return $str if ($param_error);
32
33 # get the args to be interpolated.
343327µs my $argsStr = $params->{args} || "";
35
36 # Escape any escapes.
373325µs $str =~ s#\\#\\\\#g
38 if ( $Foswiki::cfg{UserInterfaceInternationalisation}
39 && $Locale::Maketext::VERSION
40 && $Locale::Maketext::VERSION < 1.23 ); # escape any escapes
41
423347µs my @args = split( /\s*,\s*/, $argsStr );
43
44 # fill omitted args with empty strings
453337µs while ( ( scalar @args ) < $max ) {
4611µs push( @args, '' );
47 }
48
49 # do the magic:
5033149µs664.79ms my $result = $this->i18n->maketext( $str, @args );
# spent 4.62ms making 33 calls to Foswiki::i18n, avg 140µs/call # spent 173µs making 33 calls to Foswiki::I18N::Fallback::maketext, avg 5µs/call
51
52 # replace accesskeys:
533363µs $result =~
54 s#(^|[^&])&([a-zA-Z])#$1<span class='foswikiAccessKey'>$2</span>#g;
55
56 # replace escaped amperstands:
573311µs $result =~ s/&&/\&/g;
58
5933112µs return $result;
60}
61
62
# spent 44µs within Foswiki::_validate which was called 4 times, avg 11µs/call: # 4 times (44µs+0s) by Foswiki::MAKETEXT at line 28, avg 11µs/call
sub _validate {
63
64 #my ( $contents, $number, $max, $min, $param_error ) = @_
65
66414µs $_[2] = $_[1] if ( $_[1] > $_[2] ); # Record maximum param number
6745µs $_[3] = $_[1] if ( $_[1] < $_[3] ); # Record minimum param number
68
6943µs if ( $_[1] > 100 ) {
70 $_[4] = 1; # Set error flag
71 return
72"<span class=\"foswikiAlert\">Excessive parameter number $_[2], MAKETEXT rejected.</span>";
73 }
7443µs if ( $_[1] < 1 ) {
75 $_[4] = 1; # Set error flag
76 return
77"<span class=\"foswikiAlert\">Invalid parameter <code>\"$_[0]\"</code>, MAKETEXT rejected.</span>";
78 }
79426µs return "[$_[0]]"; # Return the complete bracket parameter without escapes
80}
81
8214µs1;
83__END__