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

Filename/var/www/foswiki11/lib/Foswiki/Prefs/Parser.pm
StatementsExecuted 37590 statements in 38.6ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
3351148.8ms9.69sFoswiki::Prefs::Parser::::parseFoswiki::Prefs::Parser::parse
11112µs24µsFoswiki::Prefs::Parser::::BEGIN@18Foswiki::Prefs::Parser::BEGIN@18
1119µs27µsFoswiki::Prefs::Parser::::BEGIN@20Foswiki::Prefs::Parser::BEGIN@20
1118µs13µsFoswiki::Prefs::Parser::::BEGIN@19Foswiki::Prefs::Parser::BEGIN@19
1114µs4µsFoswiki::Prefs::Parser::::BEGIN@22Foswiki::Prefs::Parser::BEGIN@22
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
2
3=begin TML
4
5---+ UNPUBLISHED package Foswiki::Prefs::Parser
6
7This Prefs-internal class is used to parse * Set and * Local statements
8from arbitrary text, and extract settings from meta objects. It is used
9by TopicPrefs to parse preference settings from topics.
10
11This class does no validation or duplicate-checking on the settings; it
12simply returns the recognized settings in the order it sees them in.
13
14=cut
15
16package Foswiki::Prefs::Parser;
17
18226µs237µs
# spent 24µs (12+12) within Foswiki::Prefs::Parser::BEGIN@18 which was called: # once (12µs+12µs) by Foswiki::Prefs::TopicRAM::BEGIN@22 at line 18
use strict;
# spent 24µs making 1 call to Foswiki::Prefs::Parser::BEGIN@18 # spent 12µs making 1 call to strict::import
19222µs218µs
# spent 13µs (8+5) within Foswiki::Prefs::Parser::BEGIN@19 which was called: # once (8µs+5µs) by Foswiki::Prefs::TopicRAM::BEGIN@22 at line 19
use warnings;
# spent 13µs making 1 call to Foswiki::Prefs::Parser::BEGIN@19 # spent 5µs making 1 call to warnings::import
20225µs246µs
# spent 27µs (9+19) within Foswiki::Prefs::Parser::BEGIN@20 which was called: # once (9µs+19µs) by Foswiki::Prefs::TopicRAM::BEGIN@22 at line 20
use Assert;
# spent 27µs making 1 call to Foswiki::Prefs::Parser::BEGIN@20 # spent 19µs making 1 call to Assert::import
21
222304µs14µs
# spent 4µs within Foswiki::Prefs::Parser::BEGIN@22 which was called: # once (4µs+0s) by Foswiki::Prefs::TopicRAM::BEGIN@22 at line 22
use Foswiki ();
# spent 4µs making 1 call to Foswiki::Prefs::Parser::BEGIN@22
23
24=begin TML
25
26---++ StaticFunction parse( $topicObject, $prefs )
27
28Parse settings from the topic and add them to the preferences in $prefs
29
30=cut
31
32
# spent 9.69s (48.8ms+9.64) within Foswiki::Prefs::Parser::parse which was called 335 times, avg 28.9ms/call: # 335 times (48.8ms+9.64s) by Foswiki::Prefs::TopicRAM::new at line 31 of /var/www/foswiki11/lib/Foswiki/Prefs/TopicRAM.pm, avg 28.9ms/call
sub parse {
33335231µs my ( $topicObject, $prefs ) = @_;
34
35 # Process text first
36335121µs my $key = '';
3733554µs my $value = '';
3833538µs my $type;
39335655µs3359.61s my $text = $topicObject->text();
# spent 9.61s making 335 calls to Foswiki::Meta::text, avg 28.7ms/call
4033568µs $text = '' unless defined $text;
41
423354.52ms foreach ( split( "\n", $text ) ) {
431010816.4ms if (m/$Foswiki::regex{setVarRegex}/os) {
4416881.77ms81010.5ms if ( defined $type ) {
# spent 10.5ms making 810 calls to Foswiki::Prefs::TopicRAM::insert, avg 13µs/call
45 $prefs->insert( $type, $key, $value );
46 }
4716881.77ms $type = $1;
481688728µs $key = $2;
4916881.43ms $value = ( defined $3 ) ? $3 : '';
50 }
51 elsif ( defined $type ) {
528771.58ms if ( /^( |\t)+ *[^\s]/ && !/$Foswiki::regex{bulletRegex}/o ) {
53
54 # follow up line, extending value
55 $value .= "\n" . $_;
56 }
57 else {
588751.75ms87511.8ms $prefs->insert( $type, $key, $value );
# spent 11.8ms making 875 calls to Foswiki::Prefs::TopicRAM::insert, avg 13µs/call
59875414µs undef $type;
60 }
61 }
62 }
6333571µs336µs if ( defined $type ) {
# spent 36µs making 3 calls to Foswiki::Prefs::TopicRAM::insert, avg 12µs/call
64 $prefs->insert( $type, $key, $value );
65 }
66
67 # Now process PREFERENCEs
68335733µs3352.50ms my @fields = $topicObject->find('PREFERENCE');
# spent 2.50ms making 335 calls to Foswiki::Meta::find, avg 7µs/call
69335361µs foreach my $field (@fields) {
7096µs my $type = $field->{type} || 'Set';
7196µs my $value = $field->{value};
7293µs my $name = $field->{name};
73916µs998µs $prefs->insert( $type, $name, $value );
# spent 98µs making 9 calls to Foswiki::Prefs::TopicRAM::insert, avg 11µs/call
74 }
75
76 # Note that the use of the "S" attribute to support settings in
77 # form fields has been deprecated.
78335534µs3352.01ms my $form = $topicObject->get('FORM');
# spent 2.01ms making 335 calls to Foswiki::Meta::get, avg 6µs/call
793351.01ms if ($form) {
80219645µs2191.76ms my @fields = $topicObject->find('FIELD');
# spent 1.76ms making 219 calls to Foswiki::Meta::find, avg 8µs/call
81219273µs foreach my $field (@fields) {
8268001.50ms my $attributes = $field->{attributes};
8368001.50ms if ( $attributes && $attributes =~ /S/o ) {
84 my $value = $field->{value};
85 my $name = $field->{name};
86 $prefs->insert( 'Set', 'FORM_' . $name, $value );
87 $prefs->insert( 'Set', $name, $value );
88 }
89 }
90 }
91}
92
9312µs1;
94__END__