← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/local/src/github.com/foswiki/core/bin/view
  Run on Sun Dec 4 17:17:59 2011
Reported on Sun Dec 4 17:26:44 2011

Filename/usr/local/src/github.com/foswiki/core/lib/Foswiki/Prefs/Parser.pm
StatementsExecuted 4637 statements in 39.2ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
421129.5ms61.1sFoswiki::Prefs::Parser::::parseFoswiki::Prefs::Parser::parse
2657315.90ms5.90msFoswiki::Prefs::Parser::::CORE:matchFoswiki::Prefs::Parser::CORE:match (opcode)
2483213.21ms3.21msFoswiki::Prefs::Parser::::CORE:regcompFoswiki::Prefs::Parser::CORE:regcomp (opcode)
11125µs33µsFoswiki::Prefs::Parser::::BEGIN@18Foswiki::Prefs::Parser::BEGIN@18
11121µs61µsFoswiki::Prefs::Parser::::BEGIN@20Foswiki::Prefs::Parser::BEGIN@20
11116µs33µsFoswiki::Prefs::Parser::::BEGIN@19Foswiki::Prefs::Parser::BEGIN@19
1119µs9µ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
18252µs241µ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
use strict;
# spent 33µs making 1 call to Foswiki::Prefs::Parser::BEGIN@18 # spent 8µs making 1 call to strict::import
19242µs250µ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
use warnings;
# spent 33µs making 1 call to Foswiki::Prefs::Parser::BEGIN@19 # spent 17µs making 1 call to warnings::import
20244µs2101µ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
use Assert;
# spent 61µs making 1 call to Foswiki::Prefs::Parser::BEGIN@20 # spent 40µs making 1 call to Assert::import
21
222650µs19µ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
use Foswiki ();
# spent 9µ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 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
sub parse {
335044.13ms my ( $topicObject, $prefs ) = @_;
34
35 # Process text first
36 my $key = '';
37 my $value = '';
38 my $type;
394261.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 ) ) {
43341431.8ms49128.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
4484462µs if ( defined $type ) {
45843.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 ) {
52250844µs180433µ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 {
581244.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
68421.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) {
7068250µs my $type = $field->{type} || 'Set';
71 my $value = $field->{value};
72 my $name = $field->{name};
7317737µ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.
7842830µs my $form = $topicObject->get('FORM');
# spent 830µs making 42 calls to Foswiki::Meta::get, avg 20µs/call
7920110µs if ($form) {
8010244µ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) {
82288819µs my $attributes = $field->{attributes};
834875µ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
9315µs1;
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:match; # opcode
# spent 3.21ms within Foswiki::Prefs::Parser::CORE:regcomp which was called 2483 times, avg 1µs/call: # 2456 times (3.16ms+0s) by Foswiki::Prefs::Parser::parse at line 43, avg 1µs/call # 27 times (51µs+0s) by Foswiki::Prefs::Parser::parse at line 52, avg 2µs/call
sub Foswiki::Prefs::Parser::CORE:regcomp; # opcode