Filename | /var/www/foswiki11/lib/Foswiki/Prefs/Parser.pm |
Statements | Executed 37590 statements in 38.6ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
335 | 1 | 1 | 48.8ms | 9.69s | parse | Foswiki::Prefs::Parser::
1 | 1 | 1 | 12µs | 24µs | BEGIN@18 | Foswiki::Prefs::Parser::
1 | 1 | 1 | 9µs | 27µs | BEGIN@20 | Foswiki::Prefs::Parser::
1 | 1 | 1 | 8µs | 13µs | BEGIN@19 | Foswiki::Prefs::Parser::
1 | 1 | 1 | 4µs | 4µs | BEGIN@22 | Foswiki::Prefs::Parser::
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 | |||||
7 | This Prefs-internal class is used to parse * Set and * Local statements | ||||
8 | from arbitrary text, and extract settings from meta objects. It is used | ||||
9 | by TopicPrefs to parse preference settings from topics. | ||||
10 | |||||
11 | This class does no validation or duplicate-checking on the settings; it | ||||
12 | simply returns the recognized settings in the order it sees them in. | ||||
13 | |||||
14 | =cut | ||||
15 | |||||
16 | package Foswiki::Prefs::Parser; | ||||
17 | |||||
18 | 2 | 26µs | 2 | 37µ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 # spent 24µs making 1 call to Foswiki::Prefs::Parser::BEGIN@18
# spent 12µs making 1 call to strict::import |
19 | 2 | 22µs | 2 | 18µ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 # spent 13µs making 1 call to Foswiki::Prefs::Parser::BEGIN@19
# spent 5µs making 1 call to warnings::import |
20 | 2 | 25µs | 2 | 46µ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 # spent 27µs making 1 call to Foswiki::Prefs::Parser::BEGIN@20
# spent 19µs making 1 call to Assert::import |
21 | |||||
22 | 2 | 304µs | 1 | 4µ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 # spent 4µs making 1 call to Foswiki::Prefs::Parser::BEGIN@22 |
23 | |||||
24 | =begin TML | ||||
25 | |||||
26 | ---++ StaticFunction parse( $topicObject, $prefs ) | ||||
27 | |||||
28 | Parse 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 | ||||
33 | 335 | 231µs | my ( $topicObject, $prefs ) = @_; | ||
34 | |||||
35 | # Process text first | ||||
36 | 335 | 121µs | my $key = ''; | ||
37 | 335 | 54µs | my $value = ''; | ||
38 | 335 | 38µs | my $type; | ||
39 | 335 | 655µs | 335 | 9.61s | my $text = $topicObject->text(); # spent 9.61s making 335 calls to Foswiki::Meta::text, avg 28.7ms/call |
40 | 335 | 68µs | $text = '' unless defined $text; | ||
41 | |||||
42 | 335 | 4.52ms | foreach ( split( "\n", $text ) ) { | ||
43 | 10108 | 16.4ms | if (m/$Foswiki::regex{setVarRegex}/os) { | ||
44 | 1688 | 1.77ms | 810 | 10.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 | } | ||||
47 | 1688 | 1.77ms | $type = $1; | ||
48 | 1688 | 728µs | $key = $2; | ||
49 | 1688 | 1.43ms | $value = ( defined $3 ) ? $3 : ''; | ||
50 | } | ||||
51 | elsif ( defined $type ) { | ||||
52 | 877 | 1.58ms | if ( /^( |\t)+ *[^\s]/ && !/$Foswiki::regex{bulletRegex}/o ) { | ||
53 | |||||
54 | # follow up line, extending value | ||||
55 | $value .= "\n" . $_; | ||||
56 | } | ||||
57 | else { | ||||
58 | 875 | 1.75ms | 875 | 11.8ms | $prefs->insert( $type, $key, $value ); # spent 11.8ms making 875 calls to Foswiki::Prefs::TopicRAM::insert, avg 13µs/call |
59 | 875 | 414µs | undef $type; | ||
60 | } | ||||
61 | } | ||||
62 | } | ||||
63 | 335 | 71µs | 3 | 36µ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 | ||||
68 | 335 | 733µs | 335 | 2.50ms | my @fields = $topicObject->find('PREFERENCE'); # spent 2.50ms making 335 calls to Foswiki::Meta::find, avg 7µs/call |
69 | 335 | 361µs | foreach my $field (@fields) { | ||
70 | 9 | 6µs | my $type = $field->{type} || 'Set'; | ||
71 | 9 | 6µs | my $value = $field->{value}; | ||
72 | 9 | 3µs | my $name = $field->{name}; | ||
73 | 9 | 16µs | 9 | 98µ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. | ||||
78 | 335 | 534µs | 335 | 2.01ms | my $form = $topicObject->get('FORM'); # spent 2.01ms making 335 calls to Foswiki::Meta::get, avg 6µs/call |
79 | 335 | 1.01ms | if ($form) { | ||
80 | 219 | 645µs | 219 | 1.76ms | my @fields = $topicObject->find('FIELD'); # spent 1.76ms making 219 calls to Foswiki::Meta::find, avg 8µs/call |
81 | 219 | 273µs | foreach my $field (@fields) { | ||
82 | 6800 | 1.50ms | my $attributes = $field->{attributes}; | ||
83 | 6800 | 1.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 | |||||
93 | 1 | 2µs | 1; | ||
94 | __END__ |