Filename | /usr/local/lib/perl5/site_perl/Mail/SpamAssassin/PerMsgLearner.pm |
Statements | Executed 3530 statements in 21.5ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
234 | 1 | 1 | 8.16ms | 8.16ms | new | Mail::SpamAssassin::PerMsgLearner::
234 | 1 | 1 | 5.31ms | 710s | learn_spam | Mail::SpamAssassin::PerMsgLearner::
234 | 1 | 1 | 3.59ms | 3.59ms | finish | Mail::SpamAssassin::PerMsgLearner::
234 | 1 | 1 | 2.29ms | 2.29ms | did_learn | Mail::SpamAssassin::PerMsgLearner::
1 | 1 | 1 | 1.79ms | 2.44ms | BEGIN@56 | Mail::SpamAssassin::PerMsgLearner::
1 | 1 | 1 | 51µs | 61µs | BEGIN@49 | Mail::SpamAssassin::PerMsgLearner::
1 | 1 | 1 | 38µs | 115µs | BEGIN@59 | Mail::SpamAssassin::PerMsgLearner::
1 | 1 | 1 | 38µs | 70µs | BEGIN@50 | Mail::SpamAssassin::PerMsgLearner::
1 | 1 | 1 | 27µs | 84µs | BEGIN@52 | Mail::SpamAssassin::PerMsgLearner::
1 | 1 | 1 | 26µs | 32µs | BEGIN@51 | Mail::SpamAssassin::PerMsgLearner::
1 | 1 | 1 | 25µs | 25µs | BEGIN@54 | Mail::SpamAssassin::PerMsgLearner::
1 | 1 | 1 | 22µs | 185µs | BEGIN@57 | Mail::SpamAssassin::PerMsgLearner::
1 | 1 | 1 | 20µs | 20µ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 | 104µs | 2 | 70µs | # spent 61µs (51+10) within Mail::SpamAssassin::PerMsgLearner::BEGIN@49 which was called:
# once (51µs+10µs) by main::BEGIN@68 at line 49 # spent 61µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@49
# spent 10µs making 1 call to strict::import |
50 | 2 | 66µs | 2 | 102µs | # spent 70µs (38+32) within Mail::SpamAssassin::PerMsgLearner::BEGIN@50 which was called:
# once (38µs+32µs) by main::BEGIN@68 at line 50 # spent 70µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@50
# spent 32µs making 1 call to warnings::import |
51 | 2 | 69µs | 2 | 38µs | # spent 32µs (26+6) within Mail::SpamAssassin::PerMsgLearner::BEGIN@51 which was called:
# once (26µs+6µs) by main::BEGIN@68 at line 51 # spent 32µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@51
# spent 6µs making 1 call to bytes::import |
52 | 2 | 61µs | 2 | 140µs | # spent 84µs (27+57) within Mail::SpamAssassin::PerMsgLearner::BEGIN@52 which was called:
# once (27µs+57µs) by main::BEGIN@68 at line 52 # spent 84µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@52
# spent 57µs making 1 call to re::import |
53 | |||||
54 | 2 | 65µs | 1 | 25µs | # spent 25µs within Mail::SpamAssassin::PerMsgLearner::BEGIN@54 which was called:
# once (25µs+0s) by main::BEGIN@68 at line 54 # spent 25µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@54 |
55 | 2 | 59µs | 1 | 20µs | # spent 20µs within Mail::SpamAssassin::PerMsgLearner::BEGIN@55 which was called:
# once (20µs+0s) by main::BEGIN@68 at line 55 # spent 20µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@55 |
56 | 2 | 313µs | 1 | 2.44ms | # spent 2.44ms (1.79+653µs) within Mail::SpamAssassin::PerMsgLearner::BEGIN@56 which was called:
# once (1.79ms+653µs) by main::BEGIN@68 at line 56 # spent 2.44ms making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@56 |
57 | 2 | 76µs | 2 | 348µs | # spent 185µs (22+163) within Mail::SpamAssassin::PerMsgLearner::BEGIN@57 which was called:
# once (22µs+163µs) by main::BEGIN@68 at line 57 # spent 185µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@57
# spent 163µs making 1 call to Exporter::import |
58 | |||||
59 | 1 | 6µs | # spent 115µs (38+77) within Mail::SpamAssassin::PerMsgLearner::BEGIN@59 which was called:
# once (38µs+77µs) by main::BEGIN@68 at line 61 | ||
60 | @ISA | ||||
61 | 1 | 743µs | 2 | 192µs | }; # spent 115µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@59
# spent 77µs making 1 call to vars::import |
62 | |||||
63 | 1 | 11µs | @ISA = qw(); | ||
64 | |||||
65 | ########################################################################### | ||||
66 | |||||
67 | # spent 8.16ms within Mail::SpamAssassin::PerMsgLearner::new which was called 234 times, avg 35µs/call:
# 234 times (8.16ms+0s) by Mail::SpamAssassin::learn at line 648 of Mail/SpamAssassin.pm, avg 35µs/call | ||||
68 | 234 | 610µs | my $class = shift; | ||
69 | 234 | 650µs | $class = ref($class) || $class; | ||
70 | 234 | 556µ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 | 234 | 2.00ms | }; | ||
78 | |||||
79 | 234 | 1.10ms | $self->{conf} = $self->{main}->{conf}; | ||
80 | |||||
81 | 234 | 1.07ms | $self->{bayes_scanner} = $self->{main}->{bayes_scanner}; | ||
82 | |||||
83 | 234 | 659µs | bless ($self, $class); | ||
84 | 234 | 1.78ms | $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 710s (5.31ms+710) within Mail::SpamAssassin::PerMsgLearner::learn_spam which was called 234 times, avg 3.03s/call:
# 234 times (5.31ms+710s) by Mail::SpamAssassin::learn at line 655 of Mail/SpamAssassin.pm, avg 3.03s/call | ||||
101 | 234 | 501µ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 | 234 | 4.63ms | 234 | 710s | $self->{learned} = $self->{bayes_scanner}->learn (1, $self->{msg}, $id); # spent 710s making 234 calls to Mail::SpamAssassin::Bayes::learn, avg 3.03s/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.29ms within Mail::SpamAssassin::PerMsgLearner::did_learn which was called 234 times, avg 10µs/call:
# 234 times (2.29ms+0s) by main::wanted at line 575 of /usr/local/bin/sa-learn, avg 10µs/call | ||||
171 | 234 | 650µs | my ($self) = @_; | ||
172 | 234 | 1.78ms | return ($self->{learned}); | ||
173 | } | ||||
174 | |||||
175 | ########################################################################### | ||||
176 | |||||
177 | =item $status->finish() | ||||
178 | |||||
179 | Finish with the object. | ||||
180 | |||||
181 | =cut | ||||
182 | |||||
183 | # spent 3.59ms within Mail::SpamAssassin::PerMsgLearner::finish which was called 234 times, avg 15µs/call:
# 234 times (3.59ms+0s) by main::wanted at line 585 of /usr/local/bin/sa-learn, avg 15µs/call | ||||
184 | 234 | 502µs | my $self = shift; | ||
185 | 468 | 3.43ms | %{$self} = (); | ||
186 | } | ||||
187 | |||||
188 | ########################################################################### | ||||
189 | |||||
190 | 1 | 14µs | 1; | ||
191 | __END__ |