← 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:36 2011

Filename/usr/local/src/github.com/foswiki/core/lib/Foswiki/Contrib/MailerContrib/Subscription.pm
StatementsExecuted 41783195 statements in 139s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
37876602267.8s81.3sFoswiki::Contrib::MailerContrib::Subscription::::matchesFoswiki::Contrib::MailerContrib::Subscription::matches
37869422153.0s134sFoswiki::Contrib::MailerContrib::Subscription::::coversFoswiki::Contrib::MailerContrib::Subscription::covers
3799840218.03s8.03sFoswiki::Contrib::MailerContrib::Subscription::::CORE:regcompFoswiki::Contrib::MailerContrib::Subscription::CORE:regcomp (opcode)
3787660115.56s5.56sFoswiki::Contrib::MailerContrib::Subscription::::CORE:matchFoswiki::Contrib::MailerContrib::Subscription::CORE:match (opcode)
1218011510ms776msFoswiki::Contrib::MailerContrib::Subscription::::newFoswiki::Contrib::MailerContrib::Subscription::new
243602149.0ms49.0msFoswiki::Contrib::MailerContrib::Subscription::::CORE:substFoswiki::Contrib::MailerContrib::Subscription::CORE:subst (opcode)
121801143.9ms43.9msFoswiki::Contrib::MailerContrib::Subscription::::CORE:qrFoswiki::Contrib::MailerContrib::Subscription::CORE:qr (opcode)
11170µs115µsFoswiki::Contrib::MailerContrib::Subscription::::BEGIN@17Foswiki::Contrib::MailerContrib::Subscription::BEGIN@17
11138µs45µsFoswiki::Contrib::MailerContrib::Subscription::::BEGIN@15Foswiki::Contrib::MailerContrib::Subscription::BEGIN@15
11125µs173µsFoswiki::Contrib::MailerContrib::Subscription::::BEGIN@20Foswiki::Contrib::MailerContrib::Subscription::BEGIN@20
11117µs35µsFoswiki::Contrib::MailerContrib::Subscription::::BEGIN@16Foswiki::Contrib::MailerContrib::Subscription::BEGIN@16
11116µs109µsFoswiki::Contrib::MailerContrib::Subscription::::BEGIN@23Foswiki::Contrib::MailerContrib::Subscription::BEGIN@23
0000s0sFoswiki::Contrib::MailerContrib::Subscription::::equalsFoswiki::Contrib::MailerContrib::Subscription::equals
0000s0sFoswiki::Contrib::MailerContrib::Subscription::::getModeFoswiki::Contrib::MailerContrib::Subscription::getMode
0000s0sFoswiki::Contrib::MailerContrib::Subscription::::stringifyFoswiki::Contrib::MailerContrib::Subscription::stringify
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---+ package Foswiki::Contrib::MailerContrib::Subscription
6Object that represents a single subscription of a user to
7notification on a page. A subscription is expressed as a page
8spec (which may contain wildcards) and a depth of children of
9matching pages that the user is subscribed to.
10
11=cut
12
13package Foswiki::Contrib::MailerContrib::Subscription;
14
15248µs253µs
# spent 45µs (38+8) within Foswiki::Contrib::MailerContrib::Subscription::BEGIN@15 which was called: # once (38µs+8µs) by Foswiki::Contrib::MailerContrib::WebNotify::BEGIN@24 at line 15
use strict;
# spent 45µs making 1 call to Foswiki::Contrib::MailerContrib::Subscription::BEGIN@15 # spent 8µs making 1 call to strict::import
16245µs252µs
# spent 35µs (17+18) within Foswiki::Contrib::MailerContrib::Subscription::BEGIN@16 which was called: # once (17µs+18µs) by Foswiki::Contrib::MailerContrib::WebNotify::BEGIN@24 at line 16
use warnings;
# spent 35µs making 1 call to Foswiki::Contrib::MailerContrib::Subscription::BEGIN@16 # spent 18µs making 1 call to warnings::import
17254µs2161µs
# spent 115µs (70+45) within Foswiki::Contrib::MailerContrib::Subscription::BEGIN@17 which was called: # once (70µs+45µs) by Foswiki::Contrib::MailerContrib::WebNotify::BEGIN@24 at line 17
use Assert;
# spent 115µs making 1 call to Foswiki::Contrib::MailerContrib::Subscription::BEGIN@17 # spent 45µs making 1 call to Assert::import
18
19# Always mail out this subscription, even if there have been no changes
20274µs2321µs
# spent 173µs (25+148) within Foswiki::Contrib::MailerContrib::Subscription::BEGIN@20 which was called: # once (25µs+148µs) by Foswiki::Contrib::MailerContrib::WebNotify::BEGIN@24 at line 20
use constant ALWAYS => 1;
# spent 173µs making 1 call to Foswiki::Contrib::MailerContrib::Subscription::BEGIN@20 # spent 148µs making 1 call to constant::import
21
22# Always mail out the full topic, not just the changes
232942µs2201µs
# spent 109µs (16+92) within Foswiki::Contrib::MailerContrib::Subscription::BEGIN@23 which was called: # once (16µs+92µs) by Foswiki::Contrib::MailerContrib::WebNotify::BEGIN@24 at line 23
use constant FULL_TOPIC => 2;
# spent 109µs making 1 call to Foswiki::Contrib::MailerContrib::Subscription::BEGIN@23 # spent 92µs making 1 call to constant::import
24
25# ? = FULL_TOPIC
26# ! = FULL_TOPIC | ALWAYS
27
28=begin TML
29
30---++ new($pages, $childDepth, $options)
31 * =$pages= - Wildcarded expression matching subscribed pages
32 * =$childDepth= - Depth of children of $topic to notify changes
33 for. Defaults to 0
34 * =$options= - bitmask of Foswiki::Contrib::MailerContrib::Subscription options
35Create a new subscription.
36
37=cut
38
39
# spent 776ms (510+266) within Foswiki::Contrib::MailerContrib::Subscription::new which was called 12180 times, avg 64µs/call: # 12180 times (510ms+266ms) by Foswiki::Contrib::MailerContrib::WebNotify::subscribe at line 143 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Contrib/MailerContrib/WebNotify.pm, avg 64µs/call
sub new {
40121800730ms my ( $class, $topics, $depth, $opts ) = @_;
41
421218040.5ms ASSERT( defined($opts) && $opts =~ /^\d*$/ ) if DEBUG;
# spent 40.5ms making 12180 calls to Assert::ASSERTS_OFF, avg 3µs/call
43
44 my $this = bless( {}, $class );
45
46 $this->{topics} = $topics || '';
47 $this->{depth} = $depth || 0;
48 $this->{options} = $opts || 0;
49
501218029.2ms $topics =~ s/[^\w\*]//g;
# spent 29.2ms making 12180 calls to Foswiki::Contrib::MailerContrib::Subscription::CORE:subst, avg 2µs/call
511218019.8ms $topics =~ s/\*/\.\*\?/g;
# spent 19.8ms making 12180 calls to Foswiki::Contrib::MailerContrib::Subscription::CORE:subst, avg 2µs/call
5224360176ms $this->{topicsRE} = qr/^$topics$/;
# spent 133ms making 12180 calls to Foswiki::Contrib::MailerContrib::Subscription::CORE:regcomp, avg 11µs/call # spent 43.9ms making 12180 calls to Foswiki::Contrib::MailerContrib::Subscription::CORE:qr, avg 4µs/call
53
54 return $this;
55}
56
57=begin TML
58
59---++ stringify() -> string
60Return a string representation of this object, in Web<nop>Notify format.
61
62=cut
63
64sub stringify {
65 my $this = shift;
66 my $record = $this->{topics};
67
68 # Protect non-alphanumerics in topic name
69 if ( $record =~ /[^*\w.]/ ) {
70 if ( $record =~ /'/ ) {
71 $record = "\"$record\"";
72 }
73 else {
74 $record = "'$record'";
75 }
76 }
77 $record .= $this->getMode();
78 $record .= " ($this->{depth})" if ( $this->{depth} );
79 return $record;
80}
81
82=begin TML
83
84---++ matches($topic, $db, $depth) -> boolean
85 * =$topic= - Topic object we are checking
86 * =$db= - Foswiki::Contrib::MailerContrib::UpData database of parent names
87 * =$depth= - If non-zero, check if the parent of the given topic matches as well. undef = 0.
88Check if we match this topic. Recurses up the parenthood tree seeing if
89this is a child of a parent that matches within the depth range.
90
91TODO: '*' should match alot of things..
92
93=cut
94
95
# spent 81.3s (67.8+13.5) within Foswiki::Contrib::MailerContrib::Subscription::matches which was called 3787660 times, avg 21µs/call: # 3786942 times (67.8s+13.5s) by Foswiki::Contrib::MailerContrib::Subscription::covers at line 139, avg 21µs/call # 718 times (13.3ms+2.65ms) by Foswiki::Contrib::MailerContrib::Subscriber::isSubscribedTo at line 215 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Contrib/MailerContrib/Subscriber.pm, avg 22µs/call
sub matches {
962651361287.1s my ( $this, $topic, $db, $depth ) = @_;
97 return 0 unless ($topic);
98
99757532013.5s return 1 if ( $topic =~ $this->{topicsRE} );
# spent 7.90s making 3787660 calls to Foswiki::Contrib::MailerContrib::Subscription::CORE:regcomp, avg 2µs/call # spent 5.56s making 3787660 calls to Foswiki::Contrib::MailerContrib::Subscription::CORE:match, avg 1µs/call
100
101 $depth = $this->{depth} unless defined($depth);
102 $depth ||= 0;
103
104 if ( $depth && $db ) {
105 my $parent = $db->getParent($topic);
106 $parent =~ s/^.*\.//;
107 return $this->matches( $parent, $db, $depth - 1 ) if ($parent);
108 }
109
110 return 0;
111}
112
113=begin TML
114
115---++ covers($other, $db) -> $boolean
116 * =$other= - Other subscription object we are checking
117 * =$db= - Foswiki::Contrib::MailerContrib::UpData database of parent names
118Return true if this subscription already covers all the topics
119specified by another subscription. Thus:
120 * A&#2A;B _covers_ AB, AxB
121 * A&#2A; _covers_ A&#2A;B
122 * &#2A;B _does not cover_ A&#2A;
123
124=cut
125
126
# spent 134s (53.0+81.3) within Foswiki::Contrib::MailerContrib::Subscription::covers which was called 3786942 times, avg 35µs/call: # 1893472 times (26.6s+40.9s) by Foswiki::Contrib::MailerContrib::Subscriber::_addAndOptimise at line 120 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Contrib/MailerContrib/Subscriber.pm, avg 36µs/call # 1893470 times (26.3s+40.4s) by Foswiki::Contrib::MailerContrib::Subscriber::_addAndOptimise at line 121 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Contrib/MailerContrib/Subscriber.pm, avg 35µs/call
sub covers {
1271514777251.0s my ( $this, $tother, $db ) = @_;
128
129 # Does the mode cover the other subscription?
130 # ALWAYS covers (ALWAYS and not ALWAYS).
131 # FULL_TOPIC covers (FULL_TOPIC and not FULL_TOPIC)
132 return 0
133 unless ( $this->{options} & $tother->{options} ) == $tother->{options};
134
135 # A * always covers if the options match
136 return 1 if ( $this->{topics} eq '*' );
137
138 # do they match without taking into account the depth?
139378694281.3s return 0 unless ( $this->matches( $tother->{topics}, undef, 0 ) );
# spent 81.3s making 3786942 calls to Foswiki::Contrib::MailerContrib::Subscription::matches, avg 21µs/call
140
141 # if we have a depth and they don't, that's already catered for
142 # by the matches test above
143
144 # if we don't have a depth and they do, then we might be covered
145 # by them, but that's irrelevant
146
147 # if we have a depth and they have a depth, then there is coverage
148 # if our depth is >= their depth
149 return 0 unless ( $this->{depth} >= $tother->{depth} );
150
151 return 1;
152}
153
154=begin TML
155
156---++ getMode() -> $mode
157Get the newsletter mode of this subscription ('', '?' or '!') as
158specified in WebNotify.
159
160=cut
161
162sub getMode {
163 my $this = shift;
164
165 if ( $this->{options} & FULL_TOPIC ) {
166 return '!'
167 if ( $this->{options} & ALWAYS );
168 return '?';
169 }
170 return '';
171}
172
173=begin TML
174
175---++ equals($other) -> $boolean
176Compare two subscriptions.
177
178=cut
179
180sub equals {
181 my ( $this, $tother ) = @_;
182 return 0 unless ( $this->{options} eq $tother->{options} );
183 return 0 unless ( $this->{depth} == $tother->{depth} );
184 return 0 unless ( $this->{topics} eq $tother->{topics} );
185}
186
18714µs1;
188__END__
 
# spent 5.56s within Foswiki::Contrib::MailerContrib::Subscription::CORE:match which was called 3787660 times, avg 1µs/call: # 3787660 times (5.56s+0s) by Foswiki::Contrib::MailerContrib::Subscription::matches at line 99, avg 1µs/call
sub Foswiki::Contrib::MailerContrib::Subscription::CORE:match; # opcode
# spent 43.9ms within Foswiki::Contrib::MailerContrib::Subscription::CORE:qr which was called 12180 times, avg 4µs/call: # 12180 times (43.9ms+0s) by Foswiki::Contrib::MailerContrib::Subscription::new at line 52, avg 4µs/call
sub Foswiki::Contrib::MailerContrib::Subscription::CORE:qr; # opcode
# spent 8.03s within Foswiki::Contrib::MailerContrib::Subscription::CORE:regcomp which was called 3799840 times, avg 2µs/call: # 3787660 times (7.90s+0s) by Foswiki::Contrib::MailerContrib::Subscription::matches at line 99, avg 2µs/call # 12180 times (133ms+0s) by Foswiki::Contrib::MailerContrib::Subscription::new at line 52, avg 11µs/call
sub Foswiki::Contrib::MailerContrib::Subscription::CORE:regcomp; # opcode
# spent 49.0ms within Foswiki::Contrib::MailerContrib::Subscription::CORE:subst which was called 24360 times, avg 2µs/call: # 12180 times (29.2ms+0s) by Foswiki::Contrib::MailerContrib::Subscription::new at line 50, avg 2µs/call # 12180 times (19.8ms+0s) by Foswiki::Contrib::MailerContrib::Subscription::new at line 51, avg 2µs/call
sub Foswiki::Contrib::MailerContrib::Subscription::CORE:subst; # opcode