Filename | /usr/local/src/github.com/foswiki/core/lib/Foswiki/Contrib/MailerContrib/Subscription.pm |
Statements | Executed 41783195 statements in 139s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
3787660 | 2 | 2 | 67.8s | 81.3s | matches | Foswiki::Contrib::MailerContrib::Subscription::
3786942 | 2 | 1 | 53.0s | 134s | covers | Foswiki::Contrib::MailerContrib::Subscription::
3799840 | 2 | 1 | 8.03s | 8.03s | CORE:regcomp (opcode) | Foswiki::Contrib::MailerContrib::Subscription::
3787660 | 1 | 1 | 5.56s | 5.56s | CORE:match (opcode) | Foswiki::Contrib::MailerContrib::Subscription::
12180 | 1 | 1 | 510ms | 776ms | new | Foswiki::Contrib::MailerContrib::Subscription::
24360 | 2 | 1 | 49.0ms | 49.0ms | CORE:subst (opcode) | Foswiki::Contrib::MailerContrib::Subscription::
12180 | 1 | 1 | 43.9ms | 43.9ms | CORE:qr (opcode) | Foswiki::Contrib::MailerContrib::Subscription::
1 | 1 | 1 | 70µs | 115µs | BEGIN@17 | Foswiki::Contrib::MailerContrib::Subscription::
1 | 1 | 1 | 38µs | 45µs | BEGIN@15 | Foswiki::Contrib::MailerContrib::Subscription::
1 | 1 | 1 | 25µs | 173µs | BEGIN@20 | Foswiki::Contrib::MailerContrib::Subscription::
1 | 1 | 1 | 17µs | 35µs | BEGIN@16 | Foswiki::Contrib::MailerContrib::Subscription::
1 | 1 | 1 | 16µs | 109µs | BEGIN@23 | Foswiki::Contrib::MailerContrib::Subscription::
0 | 0 | 0 | 0s | 0s | equals | Foswiki::Contrib::MailerContrib::Subscription::
0 | 0 | 0 | 0s | 0s | getMode | Foswiki::Contrib::MailerContrib::Subscription::
0 | 0 | 0 | 0s | 0s | stringify | Foswiki::Contrib::MailerContrib::Subscription::
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 | ||||
6 | Object that represents a single subscription of a user to | ||||
7 | notification on a page. A subscription is expressed as a page | ||||
8 | spec (which may contain wildcards) and a depth of children of | ||||
9 | matching pages that the user is subscribed to. | ||||
10 | |||||
11 | =cut | ||||
12 | |||||
13 | package Foswiki::Contrib::MailerContrib::Subscription; | ||||
14 | |||||
15 | 2 | 48µs | 2 | 53µ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 # spent 45µs making 1 call to Foswiki::Contrib::MailerContrib::Subscription::BEGIN@15
# spent 8µs making 1 call to strict::import |
16 | 2 | 45µs | 2 | 52µ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 # spent 35µs making 1 call to Foswiki::Contrib::MailerContrib::Subscription::BEGIN@16
# spent 18µs making 1 call to warnings::import |
17 | 2 | 54µs | 2 | 161µ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 # 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 | ||||
20 | 2 | 74µs | 2 | 321µ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 # 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 | ||||
23 | 2 | 942µs | 2 | 201µ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 # 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 | ||||
35 | Create 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 | ||||
40 | 12180 | 25.7ms | my ( $class, $topics, $depth, $opts ) = @_; | ||
41 | |||||
42 | 12180 | 54.5ms | 12180 | 40.5ms | ASSERT( defined($opts) && $opts =~ /^\d*$/ ) if DEBUG; # spent 40.5ms making 12180 calls to Assert::ASSERTS_OFF, avg 3µs/call |
43 | |||||
44 | 12180 | 52.2ms | my $this = bless( {}, $class ); | ||
45 | |||||
46 | 12180 | 35.2ms | $this->{topics} = $topics || ''; | ||
47 | 12180 | 22.2ms | $this->{depth} = $depth || 0; | ||
48 | 12180 | 18.7ms | $this->{options} = $opts || 0; | ||
49 | |||||
50 | 12180 | 90.2ms | 12180 | 29.2ms | $topics =~ s/[^\w\*]//g; # spent 29.2ms making 12180 calls to Foswiki::Contrib::MailerContrib::Subscription::CORE:subst, avg 2µs/call |
51 | 12180 | 69.6ms | 12180 | 19.8ms | $topics =~ s/\*/\.\*\?/g; # spent 19.8ms making 12180 calls to Foswiki::Contrib::MailerContrib::Subscription::CORE:subst, avg 2µs/call |
52 | 12180 | 293ms | 24360 | 176ms | $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 | 12180 | 68.8ms | return $this; | ||
55 | } | ||||
56 | |||||
57 | =begin TML | ||||
58 | |||||
59 | ---++ stringify() -> string | ||||
60 | Return a string representation of this object, in Web<nop>Notify format. | ||||
61 | |||||
62 | =cut | ||||
63 | |||||
64 | sub 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. | ||||
88 | Check if we match this topic. Recurses up the parenthood tree seeing if | ||||
89 | this is a child of a parent that matches within the depth range. | ||||
90 | |||||
91 | TODO: '*' 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 | ||||
96 | 3787660 | 6.31s | my ( $this, $topic, $db, $depth ) = @_; | ||
97 | 3787660 | 4.71s | return 0 unless ($topic); | ||
98 | |||||
99 | 3787660 | 42.4s | 7575320 | 13.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 | 3787658 | 4.77s | $depth = $this->{depth} unless defined($depth); | ||
102 | 3787658 | 4.93s | $depth ||= 0; | ||
103 | |||||
104 | 3787658 | 4.54s | 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 | 3787658 | 19.4s | 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 | ||||
118 | Return true if this subscription already covers all the topics | ||||
119 | specified by another subscription. Thus: | ||||
120 | * AA;B _covers_ AB, AxB | ||||
121 | * AA; _covers_ AA;B | ||||
122 | * A;B _does not cover_ AA; | ||||
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 | ||||
127 | 3786942 | 6.77s | 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 | 3786942 | 7.84s | return 0 | ||
133 | unless ( $this->{options} & $tother->{options} ) == $tother->{options}; | ||||
134 | |||||
135 | # A * always covers if the options match | ||||
136 | 3786942 | 5.38s | return 1 if ( $this->{topics} eq '*' ); | ||
137 | |||||
138 | # do they match without taking into account the depth? | ||||
139 | 3786942 | 31.0s | 3786942 | 81.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 | 2 | 5µs | return 0 unless ( $this->{depth} >= $tother->{depth} ); | ||
150 | |||||
151 | 2 | 10µs | return 1; | ||
152 | } | ||||
153 | |||||
154 | =begin TML | ||||
155 | |||||
156 | ---++ getMode() -> $mode | ||||
157 | Get the newsletter mode of this subscription ('', '?' or '!') as | ||||
158 | specified in WebNotify. | ||||
159 | |||||
160 | =cut | ||||
161 | |||||
162 | sub 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 | ||||
176 | Compare two subscriptions. | ||||
177 | |||||
178 | =cut | ||||
179 | |||||
180 | sub 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 | |||||
187 | 1 | 4µs | 1; | ||
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 | |||||
# 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 | |||||
# 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 | |||||
# 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 |