Filename | /usr/local/src/github.com/foswiki/core/lib/Foswiki/Prefs/Parser.pm |
Statements | Executed 4637 statements in 39.2ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
42 | 1 | 1 | 29.5ms | 61.1s | parse | Foswiki::Prefs::Parser::
2657 | 3 | 1 | 5.90ms | 5.90ms | CORE:match (opcode) | Foswiki::Prefs::Parser::
2483 | 2 | 1 | 3.21ms | 3.21ms | CORE:regcomp (opcode) | Foswiki::Prefs::Parser::
1 | 1 | 1 | 25µs | 33µs | BEGIN@18 | Foswiki::Prefs::Parser::
1 | 1 | 1 | 21µs | 61µs | BEGIN@20 | Foswiki::Prefs::Parser::
1 | 1 | 1 | 16µs | 33µs | BEGIN@19 | Foswiki::Prefs::Parser::
1 | 1 | 1 | 9µs | 9µ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 | 52µs | 2 | 41µs | # spent 33µs (25+8) within Foswiki::Prefs::Parser::BEGIN@18 which was called:
# once (25µs+8µs) by Foswiki::Prefs::TopicRAM::BEGIN@22 at line 18 # spent 33µs making 1 call to Foswiki::Prefs::Parser::BEGIN@18
# spent 8µs making 1 call to strict::import |
19 | 2 | 42µs | 2 | 50µs | # spent 33µs (16+17) within Foswiki::Prefs::Parser::BEGIN@19 which was called:
# once (16µs+17µs) by Foswiki::Prefs::TopicRAM::BEGIN@22 at line 19 # spent 33µs making 1 call to Foswiki::Prefs::Parser::BEGIN@19
# spent 17µs making 1 call to warnings::import |
20 | 2 | 44µs | 2 | 101µs | # spent 61µs (21+40) within Foswiki::Prefs::Parser::BEGIN@20 which was called:
# once (21µs+40µs) by Foswiki::Prefs::TopicRAM::BEGIN@22 at line 20 # spent 61µs making 1 call to Foswiki::Prefs::Parser::BEGIN@20
# spent 40µs making 1 call to Assert::import |
21 | |||||
22 | 2 | 650µs | 1 | 9µs | # spent 9µs within Foswiki::Prefs::Parser::BEGIN@22 which was called:
# once (9µs+0s) by Foswiki::Prefs::TopicRAM::BEGIN@22 at line 22 # spent 9µ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 61.1s (29.5ms+61.0) within Foswiki::Prefs::Parser::parse which was called 42 times, avg 1.45s/call:
# 42 times (29.5ms+61.0s) by Foswiki::Prefs::TopicRAM::new at line 32 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Prefs/TopicRAM.pm, avg 1.45s/call | ||||
33 | 4628 | 38.4ms | my ( $topicObject, $prefs ) = @_; | ||
34 | |||||
35 | # Process text first | ||||
36 | my $key = ''; | ||||
37 | my $value = ''; | ||||
38 | my $type; | ||||
39 | 42 | 61.0s | my $text = $topicObject->text(); # spent 61.0s making 42 calls to Foswiki::Meta::text, avg 1.45s/call | ||
40 | $text = '' unless defined $text; | ||||
41 | |||||
42 | foreach ( split( "\n", $text ) ) { | ||||
43 | 4912 | 8.61ms | if (m/$Foswiki::regex{setVarRegex}/os) { # spent 5.44ms making 2456 calls to Foswiki::Prefs::Parser::CORE:match, avg 2µs/call
# spent 3.16ms making 2456 calls to Foswiki::Prefs::Parser::CORE:regcomp, avg 1µs/call | ||
44 | if ( defined $type ) { | ||||
45 | 84 | 3.30ms | $prefs->insert( $type, $key, $value ); # spent 3.30ms making 84 calls to Foswiki::Prefs::TopicRAM::insert, avg 39µs/call | ||
46 | } | ||||
47 | $type = $1; | ||||
48 | $key = $2; | ||||
49 | $value = ( defined $3 ) ? $3 : ''; | ||||
50 | } | ||||
51 | elsif ( defined $type ) { | ||||
52 | 180 | 433µs | if ( /^( |\t)+ *[^\s]/ && !/$Foswiki::regex{bulletRegex}/o ) { # spent 382µs making 153 calls to Foswiki::Prefs::Parser::CORE:match, avg 2µs/call
# spent 51µs making 27 calls to Foswiki::Prefs::Parser::CORE:regcomp, avg 2µs/call | ||
53 | |||||
54 | # follow up line, extending value | ||||
55 | $value .= "\n" . $_; | ||||
56 | } | ||||
57 | else { | ||||
58 | 124 | 4.97ms | $prefs->insert( $type, $key, $value ); # spent 4.97ms making 124 calls to Foswiki::Prefs::TopicRAM::insert, avg 40µs/call | ||
59 | undef $type; | ||||
60 | } | ||||
61 | } | ||||
62 | } | ||||
63 | if ( defined $type ) { | ||||
64 | $prefs->insert( $type, $key, $value ); | ||||
65 | } | ||||
66 | |||||
67 | # Now process PREFERENCEs | ||||
68 | 42 | 1.10ms | my @fields = $topicObject->find('PREFERENCE'); # spent 1.10ms making 42 calls to Foswiki::Meta::find, avg 26µs/call | ||
69 | foreach my $field (@fields) { | ||||
70 | my $type = $field->{type} || 'Set'; | ||||
71 | my $value = $field->{value}; | ||||
72 | my $name = $field->{name}; | ||||
73 | 17 | 737µs | $prefs->insert( $type, $name, $value ); # spent 737µs making 17 calls to Foswiki::Prefs::TopicRAM::insert, avg 43µs/call | ||
74 | } | ||||
75 | |||||
76 | # Note that the use of the "S" attribute to support settings in | ||||
77 | # form fields has been deprecated. | ||||
78 | 42 | 830µs | my $form = $topicObject->get('FORM'); # spent 830µs making 42 calls to Foswiki::Meta::get, avg 20µs/call | ||
79 | if ($form) { | ||||
80 | 10 | 244µs | my @fields = $topicObject->find('FIELD'); # spent 244µs making 10 calls to Foswiki::Meta::find, avg 24µs/call | ||
81 | foreach my $field (@fields) { | ||||
82 | my $attributes = $field->{attributes}; | ||||
83 | 48 | 75µs | if ( $attributes && $attributes =~ /S/o ) { # spent 75µs making 48 calls to Foswiki::Prefs::Parser::CORE:match, avg 2µs/call | ||
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 | 5µs | 1; | ||
94 | __END__ | ||||
# spent 5.90ms within Foswiki::Prefs::Parser::CORE:match which was called 2657 times, avg 2µs/call:
# 2456 times (5.44ms+0s) by Foswiki::Prefs::Parser::parse at line 43, avg 2µs/call
# 153 times (382µs+0s) by Foswiki::Prefs::Parser::parse at line 52, avg 2µs/call
# 48 times (75µs+0s) by Foswiki::Prefs::Parser::parse at line 83, avg 2µs/call | |||||
sub Foswiki::Prefs::Parser::CORE:regcomp; # opcode |