Filename | /usr/local/lib/perl5/site_perl/Mail/SpamAssassin/PerMsgLearner.pm |
Statements | Executed 3545 statements in 28.3ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
235 | 1 | 1 | 7.89ms | 7.89ms | new | Mail::SpamAssassin::PerMsgLearner::
235 | 1 | 1 | 5.33ms | 1570s | learn_spam | Mail::SpamAssassin::PerMsgLearner::
235 | 1 | 1 | 3.49ms | 3.49ms | finish | Mail::SpamAssassin::PerMsgLearner::
235 | 1 | 1 | 2.25ms | 2.25ms | did_learn | Mail::SpamAssassin::PerMsgLearner::
1 | 1 | 1 | 1.79ms | 2.41ms | BEGIN@56 | Mail::SpamAssassin::PerMsgLearner::
1 | 1 | 1 | 55µs | 92µs | BEGIN@50 | Mail::SpamAssassin::PerMsgLearner::
1 | 1 | 1 | 44µs | 54µs | BEGIN@49 | Mail::SpamAssassin::PerMsgLearner::
1 | 1 | 1 | 26µs | 212µs | BEGIN@57 | Mail::SpamAssassin::PerMsgLearner::
1 | 1 | 1 | 24µs | 99µs | BEGIN@59 | Mail::SpamAssassin::PerMsgLearner::
1 | 1 | 1 | 23µs | 30µs | BEGIN@51 | Mail::SpamAssassin::PerMsgLearner::
1 | 1 | 1 | 23µs | 81µs | BEGIN@52 | Mail::SpamAssassin::PerMsgLearner::
1 | 1 | 1 | 20µs | 20µs | BEGIN@54 | Mail::SpamAssassin::PerMsgLearner::
1 | 1 | 1 | 17µs | 17µs | BEGIN@55 | Mail::SpamAssassin::PerMsgLearner::
0 | 0 | 0 | 0s | 0s | forget | Mail::SpamAssassin::PerMsgLearner::
0 | 0 | 0 | 0s | 0s | learn_ham | Mail::SpamAssassin::PerMsgLearner::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # <@LICENSE> | ||||
2 | # Licensed to the Apache Software Foundation (ASF) under one or more | ||||
3 | # contributor license agreements. See the NOTICE file distributed with | ||||
4 | # this work for additional information regarding copyright ownership. | ||||
5 | # The ASF licenses this file to you under the Apache License, Version 2.0 | ||||
6 | # (the "License"); you may not use this file except in compliance with | ||||
7 | # the License. You may obtain a copy of the License at: | ||||
8 | # | ||||
9 | # http://www.apache.org/licenses/LICENSE-2.0 | ||||
10 | # | ||||
11 | # Unless required by applicable law or agreed to in writing, software | ||||
12 | # distributed under the License is distributed on an "AS IS" BASIS, | ||||
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
14 | # See the License for the specific language governing permissions and | ||||
15 | # limitations under the License. | ||||
16 | # </@LICENSE> | ||||
17 | |||||
18 | =head1 NAME | ||||
19 | |||||
20 | Mail::SpamAssassin::PerMsgLearner - per-message status (spam or not-spam) | ||||
21 | |||||
22 | =head1 SYNOPSIS | ||||
23 | |||||
24 | my $spamtest = new Mail::SpamAssassin ({ | ||||
25 | 'rules_filename' => '/etc/spamassassin.rules', | ||||
26 | 'userprefs_filename' => $ENV{HOME}.'/.spamassassin/user_prefs' | ||||
27 | }); | ||||
28 | my $mail = $spamtest->parse(); | ||||
29 | |||||
30 | my $status = $spamtest->learn($mail,$id,$isspam,$forget); | ||||
31 | my $didlearn = $status->did_learn(); | ||||
32 | $status->finish(); | ||||
33 | |||||
34 | |||||
35 | =head1 DESCRIPTION | ||||
36 | |||||
37 | The Mail::SpamAssassin C<learn()> method returns an object of this | ||||
38 | class. This object encapsulates all the per-message state for | ||||
39 | the learning process. | ||||
40 | |||||
41 | =head1 METHODS | ||||
42 | |||||
43 | =over 4 | ||||
44 | |||||
45 | =cut | ||||
46 | |||||
47 | package Mail::SpamAssassin::PerMsgLearner; | ||||
48 | |||||
49 | 2 | 120µs | 2 | 64µs | # spent 54µs (44+10) within Mail::SpamAssassin::PerMsgLearner::BEGIN@49 which was called:
# once (44µs+10µs) by main::BEGIN@68 at line 49 # spent 54µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@49
# spent 10µs making 1 call to strict::import |
50 | 2 | 72µs | 2 | 128µs | # spent 92µs (55+36) within Mail::SpamAssassin::PerMsgLearner::BEGIN@50 which was called:
# once (55µs+36µs) by main::BEGIN@68 at line 50 # spent 92µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@50
# spent 36µs making 1 call to warnings::import |
51 | 2 | 70µs | 2 | 36µs | # spent 30µs (23+6) within Mail::SpamAssassin::PerMsgLearner::BEGIN@51 which was called:
# once (23µs+6µs) by main::BEGIN@68 at line 51 # spent 30µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@51
# spent 6µs making 1 call to bytes::import |
52 | 2 | 71µs | 2 | 140µs | # spent 81µs (23+58) within Mail::SpamAssassin::PerMsgLearner::BEGIN@52 which was called:
# once (23µs+58µs) by main::BEGIN@68 at line 52 # spent 81µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@52
# spent 58µs making 1 call to re::import |
53 | |||||
54 | 2 | 73µs | 1 | 20µs | # spent 20µs within Mail::SpamAssassin::PerMsgLearner::BEGIN@54 which was called:
# once (20µs+0s) by main::BEGIN@68 at line 54 # spent 20µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@54 |
55 | 2 | 61µs | 1 | 17µs | # spent 17µs within Mail::SpamAssassin::PerMsgLearner::BEGIN@55 which was called:
# once (17µs+0s) by main::BEGIN@68 at line 55 # spent 17µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@55 |
56 | 2 | 306µs | 1 | 2.41ms | # spent 2.41ms (1.79+621µs) within Mail::SpamAssassin::PerMsgLearner::BEGIN@56 which was called:
# once (1.79ms+621µs) by main::BEGIN@68 at line 56 # spent 2.41ms making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@56 |
57 | 2 | 76µs | 2 | 398µs | # spent 212µs (26+186) within Mail::SpamAssassin::PerMsgLearner::BEGIN@57 which was called:
# once (26µs+186µs) by main::BEGIN@68 at line 57 # spent 212µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@57
# spent 186µs making 1 call to Exporter::import |
58 | |||||
59 | 1 | 2µs | # spent 99µs (24+75) within Mail::SpamAssassin::PerMsgLearner::BEGIN@59 which was called:
# once (24µs+75µs) by main::BEGIN@68 at line 61 | ||
60 | @ISA | ||||
61 | 1 | 733µs | 2 | 173µs | }; # spent 99µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@59
# spent 75µs making 1 call to vars::import |
62 | |||||
63 | 1 | 8µs | @ISA = qw(); | ||
64 | |||||
65 | ########################################################################### | ||||
66 | |||||
67 | # spent 7.89ms within Mail::SpamAssassin::PerMsgLearner::new which was called 235 times, avg 34µs/call:
# 235 times (7.89ms+0s) by Mail::SpamAssassin::learn at line 648 of Mail/SpamAssassin.pm, avg 34µs/call | ||||
68 | 235 | 582µs | my $class = shift; | ||
69 | 235 | 639µs | $class = ref($class) || $class; | ||
70 | 235 | 519µs | my ($main, $msg) = @_; | ||
71 | |||||
72 | my $self = { | ||||
73 | 'main' => $main, | ||||
74 | 'msg' => $msg, | ||||
75 | 'learned' => 0, | ||||
76 | 'master_deadline' => $msg->{master_deadline}, # dflt inherited from msg | ||||
77 | 235 | 2.13ms | }; | ||
78 | |||||
79 | 235 | 947µs | $self->{conf} = $self->{main}->{conf}; | ||
80 | |||||
81 | 235 | 938µs | $self->{bayes_scanner} = $self->{main}->{bayes_scanner}; | ||
82 | |||||
83 | 235 | 644µs | bless ($self, $class); | ||
84 | 235 | 1.76ms | $self; | ||
85 | } | ||||
86 | |||||
87 | ########################################################################### | ||||
88 | |||||
89 | # $status->learn_spam($id) | ||||
90 | # | ||||
91 | # Learn the message as spam. | ||||
92 | # | ||||
93 | # C<$id> is an optional message-identification string, used internally | ||||
94 | # to tag the message. If it is C<undef>, one will be generated. | ||||
95 | # It should be unique to that message. | ||||
96 | # | ||||
97 | # This is a semi-private API; callers should use | ||||
98 | # C<$spamtest-E<gt>learn($mail,$id,$isspam,$forget)> instead. | ||||
99 | |||||
100 | # spent 1570s (5.33ms+1570) within Mail::SpamAssassin::PerMsgLearner::learn_spam which was called 235 times, avg 6.68s/call:
# 235 times (5.33ms+1570s) by Mail::SpamAssassin::learn at line 655 of Mail/SpamAssassin.pm, avg 6.68s/call | ||||
101 | 235 | 510µs | my ($self, $id) = @_; | ||
102 | |||||
103 | # bug 4096 | ||||
104 | # if ($self->{main}->{learn_with_whitelist}) { | ||||
105 | # $self->{main}->add_all_addresses_to_blacklist ($self->{msg}); | ||||
106 | # } | ||||
107 | |||||
108 | # use the real message-id here instead of mass-check's idea of an "id", | ||||
109 | # as we may deliver the msg into another mbox format but later need | ||||
110 | # to forget it's training. | ||||
111 | 235 | 11.6ms | 235 | 1570s | $self->{learned} = $self->{bayes_scanner}->learn (1, $self->{msg}, $id); # spent 1570s making 235 calls to Mail::SpamAssassin::Bayes::learn, avg 6.68s/call |
112 | } | ||||
113 | |||||
114 | ########################################################################### | ||||
115 | |||||
116 | # $status->learn_ham($id) | ||||
117 | # | ||||
118 | # Learn the message as ham. | ||||
119 | # | ||||
120 | # C<$id> is an optional message-identification string, used internally | ||||
121 | # to tag the message. If it is C<undef>, one will be generated. | ||||
122 | # It should be unique to that message. | ||||
123 | # | ||||
124 | # This is a semi-private API; callers should use | ||||
125 | # C<$spamtest-E<gt>learn($mail,$id,$isspam,$forget)> instead. | ||||
126 | |||||
127 | sub learn_ham { | ||||
128 | my ($self, $id) = @_; | ||||
129 | |||||
130 | # bug 4096 | ||||
131 | # if ($self->{main}->{learn_with_whitelist}) { | ||||
132 | # $self->{main}->add_all_addresses_to_whitelist ($self->{msg}); | ||||
133 | # } | ||||
134 | |||||
135 | $self->{learned} = $self->{bayes_scanner}->learn (0, $self->{msg}, $id); | ||||
136 | } | ||||
137 | |||||
138 | ########################################################################### | ||||
139 | |||||
140 | # $status->forget($id) | ||||
141 | # | ||||
142 | # Forget about a previously-learned message. | ||||
143 | # | ||||
144 | # C<$id> is an optional message-identification string, used internally | ||||
145 | # to tag the message. If it is C<undef>, one will be generated. | ||||
146 | # It should be unique to that message. | ||||
147 | # | ||||
148 | # This is a semi-private API; callers should use | ||||
149 | # C<$spamtest-E<gt>learn($mail,$id,$isspam,$forget)> instead. | ||||
150 | |||||
151 | sub forget { | ||||
152 | my ($self, $id) = @_; | ||||
153 | |||||
154 | # bug 4096 | ||||
155 | # if ($self->{main}->{learn_with_whitelist}) { | ||||
156 | # $self->{main}->remove_all_addresses_from_whitelist ($self->{msg}); | ||||
157 | # } | ||||
158 | |||||
159 | $self->{learned} = $self->{bayes_scanner}->forget ($self->{msg}, $id); | ||||
160 | } | ||||
161 | |||||
162 | ########################################################################### | ||||
163 | |||||
164 | =item $didlearn = $status->did_learn() | ||||
165 | |||||
166 | Returns C<1> if the message was learned from or forgotten successfully. | ||||
167 | |||||
168 | =cut | ||||
169 | |||||
170 | # spent 2.25ms within Mail::SpamAssassin::PerMsgLearner::did_learn which was called 235 times, avg 10µs/call:
# 235 times (2.25ms+0s) by main::wanted at line 575 of /usr/local/bin/sa-learn, avg 10µs/call | ||||
171 | 235 | 653µs | my ($self) = @_; | ||
172 | 235 | 1.72ms | return ($self->{learned}); | ||
173 | } | ||||
174 | |||||
175 | ########################################################################### | ||||
176 | |||||
177 | =item $status->finish() | ||||
178 | |||||
179 | Finish with the object. | ||||
180 | |||||
181 | =cut | ||||
182 | |||||
183 | # spent 3.49ms within Mail::SpamAssassin::PerMsgLearner::finish which was called 235 times, avg 15µs/call:
# 235 times (3.49ms+0s) by main::wanted at line 585 of /usr/local/bin/sa-learn, avg 15µs/call | ||||
184 | 235 | 513µs | my $self = shift; | ||
185 | 470 | 3.52ms | %{$self} = (); | ||
186 | } | ||||
187 | |||||
188 | ########################################################################### | ||||
189 | |||||
190 | 1 | 11µs | 1; | ||
191 | __END__ |