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

Filename/var/www/foswikidev/core/lib/Foswiki/Prefs/Parser.pm
StatementsExecuted 5709 statements in 7.00ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
29116.95ms45.0msFoswiki::Prefs::Parser::::parseFoswiki::Prefs::Parser::parse
11113µs26µsFoswiki::Prefs::Parser::::BEGIN@18Foswiki::Prefs::Parser::BEGIN@18
11110µs34µsFoswiki::Prefs::Parser::::BEGIN@20Foswiki::Prefs::Parser::BEGIN@20
1119µs13µsFoswiki::Prefs::Parser::::BEGIN@19Foswiki::Prefs::Parser::BEGIN@19
1115µs5µsFoswiki::Prefs::Parser::::BEGIN@24Foswiki::Prefs::Parser::BEGIN@24
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µs238µs
# spent 26µs (13+12) within Foswiki::Prefs::Parser::BEGIN@18 which was called: # once (13µs+12µs) by Foswiki::Prefs::TopicRAM::BEGIN@22 at line 18
use strict;
# spent 26µs making 1 call to Foswiki::Prefs::Parser::BEGIN@18 # spent 12µs making 1 call to strict::import
19223µs217µs
# spent 13µs (9+4) within Foswiki::Prefs::Parser::BEGIN@19 which was called: # once (9µs+4µ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 4µs making 1 call to warnings::import
20224µs259µs
# spent 34µs (10+25) within Foswiki::Prefs::Parser::BEGIN@20 which was called: # once (10µs+25µs) by Foswiki::Prefs::TopicRAM::BEGIN@22 at line 20
use Assert;
# spent 34µs making 1 call to Foswiki::Prefs::Parser::BEGIN@20 # spent 25µs making 1 call to Exporter::import
21
22242µ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
# spent 5µs within Foswiki::Prefs::Parser::BEGIN@24 which was called: # once (5µs+0s) by Foswiki::Prefs::TopicRAM::BEGIN@22 at line 29
BEGIN {
2519µs if ( $Foswiki::cfg{UseLocale} ) {
26 require locale;
27 import locale();
28 }
291326µs15µs}
# spent 5µs making 1 call to Foswiki::Prefs::Parser::BEGIN@24
30
31=begin TML
32
33---++ StaticFunction parse( $topicObject, $prefs )
34
35Parse settings from the topic and add them to the preferences in $prefs
36
37=cut
38
39
# spent 45.0ms (6.95+38.1) within Foswiki::Prefs::Parser::parse which was called 29 times, avg 1.55ms/call: # 29 times (6.95ms+38.1ms) by Foswiki::Prefs::TopicRAM::new at line 38 of /var/www/foswikidev/core/lib/Foswiki/Prefs/TopicRAM.pm, avg 1.55ms/call
sub parse {
402914µs my ( $topicObject, $prefs ) = @_;
41
42 # Process text first
43297µs my $key = '';
44295µs my $value = '';
45294µs my $type;
462944µs2934.1ms my $text = $topicObject->text();
# spent 34.1ms making 29 calls to Foswiki::Meta::text, avg 1.18ms/call
47295µs $text = '' unless defined $text;
48
49291.53ms foreach ( split( "\n", $text ) ) {
5030003.35ms if (m/$Foswiki::regex{setVarRegex}/s) {
51413246µs1821.56ms if ( defined $type ) {
# spent 1.56ms making 182 calls to Foswiki::Prefs::TopicRAM::insert, avg 9µs/call
52 $prefs->insert( $type, $key, $value );
53 }
54413258µs $type = $1;
5541396µs $key = $2;
56413207µs $value = ( defined $3 ) ? $3 : '';
57 }
58 elsif ( defined $type ) {
59233263µs if ( /^( |\t)+ *[^\s]/ && !/$Foswiki::regex{bulletRegex}/ ) {
60
61 # follow up line, extending value
62 $value .= "\n" . $_;
63 }
64 else {
65231265µs2312.23ms $prefs->insert( $type, $key, $value );
# spent 2.23ms making 231 calls to Foswiki::Prefs::TopicRAM::insert, avg 10µs/call
6623174µs undef $type;
67 }
68 }
69 }
70296µs if ( defined $type ) {
71 $prefs->insert( $type, $key, $value );
72 }
73
74 # Now process PREFERENCEs
752952µs2986µs my @fields = $topicObject->find('PREFERENCE');
# spent 86µs making 29 calls to Foswiki::Meta::find, avg 3µs/call
762923µs foreach my $field (@fields) {
771900ns my $type = $field->{type} || 'Set';
781500ns my $value = $field->{value};
791500ns my $name = $field->{name};
8012µs110µs $prefs->insert( $type, $name, $value );
# spent 10µs making 1 call to Foswiki::Prefs::TopicRAM::insert
81 }
82
83 # Note that the use of the "S" attribute to support settings in
84 # form fields has been deprecated.
852937µs2956µs my $form = $topicObject->get('FORM');
# spent 56µs making 29 calls to Foswiki::Meta::get, avg 2µs/call
862960µs if ($form) {
87 my @fields = $topicObject->find('FIELD');
88 foreach my $field (@fields) {
89 my $attributes = $field->{attributes};
90 if ( $attributes && $attributes =~ m/S/ ) {
91 my $value = $field->{value};
92 my $name = $field->{name};
93 $prefs->insert( 'Set', 'FORM_' . $name, $value );
94 $prefs->insert( 'Set', $name, $value );
95 }
96 }
97 }
98}
99
10012µs1;
101__END__