← Index
NYTProf Performance Profile   « line view »
For ./view
  Run on Fri Jul 31 18:42:36 2015
Reported on Fri Jul 31 18:48:15 2015

Filename/var/www/foswikidev/core/lib/Foswiki/Macros/MAKETEXT.pm
StatementsExecuted 1332 statements in 1.79ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1113.77ms7.19msFoswiki::::BEGIN@7.60Foswiki::BEGIN@7.60
57111.18ms3.90msFoswiki::::MAKETEXTFoswiki::MAKETEXT
2111116µs116µsFoswiki::::_validateFoswiki::_validate
11114µs27µsFoswiki::::BEGIN@4.58Foswiki::BEGIN@4.58
11113µs16µsFoswiki::::BEGIN@5.59Foswiki::BEGIN@5.59
1115µs5µsFoswiki::::BEGIN@9.61Foswiki::BEGIN@9.61
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
4227µs240µs
# spent 27µs (14+13) within Foswiki::BEGIN@4.58 which was called: # once (14µs+13µs) by Foswiki::_expandMacroOnTopicRendering at line 4
use strict;
# spent 27µs making 1 call to Foswiki::BEGIN@4.58 # spent 13µs making 1 call to strict::import
5224µs220µs
# spent 16µs (13+4) within Foswiki::BEGIN@5.59 which was called: # once (13µs+4µs) by Foswiki::_expandMacroOnTopicRendering at line 5
use warnings;
# spent 16µs making 1 call to Foswiki::BEGIN@5.59 # spent 4µs making 1 call to warnings::import
6
72144µs17.19ms
# spent 7.19ms (3.77+3.42) within Foswiki::BEGIN@7.60 which was called: # once (3.77ms+3.42ms) by Foswiki::_expandMacroOnTopicRendering at line 7
use Locale::Maketext;
# spent 7.19ms making 1 call to Foswiki::BEGIN@7.60
8
9
# spent 5µs within Foswiki::BEGIN@9.61 which was called: # once (5µs+0s) by Foswiki::_expandMacroOnTopicRendering at line 14
BEGIN {
1015µs if ( $Foswiki::cfg{UseLocale} ) {
11 require locale;
12 import locale();
13 }
141385µs15µs}
# spent 5µs making 1 call to Foswiki::BEGIN@9.61
15
16
# spent 3.90ms (1.18+2.72) within Foswiki::MAKETEXT which was called 57 times, avg 68µs/call: # 57 times (1.18ms+2.72ms) by Foswiki::_expandMacroOnTopicRendering at line 3435 of /var/www/foswikidev/core/lib/Foswiki.pm, avg 68µs/call
sub MAKETEXT {
175733µs my ( $this, $params ) = @_;
18
195735µs my $str = $params->{_DEFAULT} || $params->{string} || "";
205710µs return "" unless $str;
21
22 # escape everything:
235770µs $str =~ s/\[/~[/g;
245742µs $str =~ s/\]/~]/g;
25
26 # restore already escaped stuff:
275727µs $str =~ s/~~+\[/~[/g;
285723µs $str =~ s/~~+\]/~]/g;
29
305713µs my $max = 0;
31578µs my $min = 1;
32579µs my $param_error = 0;
33
34 # unescape parameters and calculate highest parameter number:
3578134µs21116µs $str =~ s/~\[(\_(\d+))~\]/_validate($1, $2, $max, $min, $param_error)/ge;
# spent 116µs making 21 calls to Foswiki::_validate, avg 6µs/call
36 $str =~
375724µss/~\[(\*,\_(\d+),[^,]+(,([^,]+))?)~\]/ _validate($1, $2, $max, $min, $param_error)/ge;
38576µs return $str if ($param_error);
39
40 # get the args to be interpolated.
415728µs my $argsStr = $params->{args} || "";
42
43 # Escape any escapes.
445726µs $str =~ s#\\#\\\\#g
45 if ( $Foswiki::cfg{UserInterfaceInternationalisation}
46 && $Locale::Maketext::VERSION
47 && $Locale::Maketext::VERSION < 1.23 ); # escape any escapes
48
495786µs my @args = split( /\s*,\s*/, $argsStr );
50
51 # fill omitted args with empty strings
525741µs while ( ( scalar(@args) ) < $max ) {
5311µs push( @args, '' );
54 }
55
56 # do the magic:
5757164µs1142.60ms my $result = $this->i18n->maketext( $str, @args );
# spent 2.34ms making 57 calls to Foswiki::i18n, avg 41µs/call # spent 270µs making 57 calls to Foswiki::I18N::Fallback::maketext, avg 5µs/call
58
59 # replace accesskeys:
6057116µs $result =~
61 s#(^|[^&])&([a-zA-Z])#$1<span class='foswikiAccessKey'>$2</span>#g;
62
63 # replace escaped amperstands:
645725µs $result =~ s/&&/\&/g;
65
6657139µs return $result;
67}
68
69
# spent 116µs within Foswiki::_validate which was called 21 times, avg 6µs/call: # 21 times (116µs+0s) by Foswiki::MAKETEXT at line 35, avg 6µs/call
sub _validate {
70
71 #my ( $contents, $number, $max, $min, $param_error ) = @_
72
732143µs $_[2] = $_[1] if ( $_[1] > $_[2] ); # Record maximum param number
742112µs $_[3] = $_[1] if ( $_[1] < $_[3] ); # Record minimum param number
75
76218µs if ( $_[1] > 100 ) {
77 $_[4] = 1; # Set error flag
78 return
79"<span class=\"foswikiAlert\">Excessive parameter number $_[2], MAKETEXT rejected.</span>";
80 }
81218µs if ( $_[1] < 1 ) {
82 $_[4] = 1; # Set error flag
83 return
84"<span class=\"foswikiAlert\">Invalid parameter <code>\"$_[0]\"</code>, MAKETEXT rejected.</span>";
85 }
862172µs return "[$_[0]]"; # Return the complete bracket parameter without escapes
87}
88
8912µs1;
90__END__