← Index
NYTProf Performance Profile   « line view »
For /usr/local/bin/sa-learn
  Run on Sun Nov 5 03:09:29 2017
Reported on Mon Nov 6 13:20:48 2017

Filename/usr/local/lib/perl5/site_perl/Mail/SpamAssassin/PerMsgLearner.pm
StatementsExecuted 3530 statements in 28.6ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
234118.04ms8.04msMail::SpamAssassin::PerMsgLearner::::newMail::SpamAssassin::PerMsgLearner::new
234115.46ms96432sMail::SpamAssassin::PerMsgLearner::::learn_spamMail::SpamAssassin::PerMsgLearner::learn_spam
234113.72ms3.72msMail::SpamAssassin::PerMsgLearner::::finishMail::SpamAssassin::PerMsgLearner::finish
234112.40ms2.40msMail::SpamAssassin::PerMsgLearner::::did_learnMail::SpamAssassin::PerMsgLearner::did_learn
1111.66ms2.16msMail::SpamAssassin::PerMsgLearner::::BEGIN@56Mail::SpamAssassin::PerMsgLearner::BEGIN@56
11148µs62µsMail::SpamAssassin::PerMsgLearner::::BEGIN@49Mail::SpamAssassin::PerMsgLearner::BEGIN@49
11132µs76µsMail::SpamAssassin::PerMsgLearner::::BEGIN@50Mail::SpamAssassin::PerMsgLearner::BEGIN@50
11124µs104µsMail::SpamAssassin::PerMsgLearner::::BEGIN@59Mail::SpamAssassin::PerMsgLearner::BEGIN@59
11123µs29µsMail::SpamAssassin::PerMsgLearner::::BEGIN@51Mail::SpamAssassin::PerMsgLearner::BEGIN@51
11123µs150µsMail::SpamAssassin::PerMsgLearner::::BEGIN@57Mail::SpamAssassin::PerMsgLearner::BEGIN@57
11123µs92µsMail::SpamAssassin::PerMsgLearner::::BEGIN@52Mail::SpamAssassin::PerMsgLearner::BEGIN@52
11117µs17µsMail::SpamAssassin::PerMsgLearner::::BEGIN@55Mail::SpamAssassin::PerMsgLearner::BEGIN@55
11114µs14µsMail::SpamAssassin::PerMsgLearner::::BEGIN@54Mail::SpamAssassin::PerMsgLearner::BEGIN@54
0000s0sMail::SpamAssassin::PerMsgLearner::::forgetMail::SpamAssassin::PerMsgLearner::forget
0000s0sMail::SpamAssassin::PerMsgLearner::::learn_hamMail::SpamAssassin::PerMsgLearner::learn_ham
Call graph for these subroutines as a Graphviz dot language file.
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
20Mail::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
37The Mail::SpamAssassin C<learn()> method returns an object of this
38class. This object encapsulates all the per-message state for
39the learning process.
40
41=head1 METHODS
42
43=over 4
44
45=cut
46
47package Mail::SpamAssassin::PerMsgLearner;
48
492105µs275µs
# spent 62µs (48+13) within Mail::SpamAssassin::PerMsgLearner::BEGIN@49 which was called: # once (48µs+13µs) by main::BEGIN@68 at line 49
use strict;
# spent 62µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@49 # spent 13µs making 1 call to strict::import
50258µs2121µs
# spent 76µs (32+44) within Mail::SpamAssassin::PerMsgLearner::BEGIN@50 which was called: # once (32µs+44µs) by main::BEGIN@68 at line 50
use warnings;
# spent 76µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@50 # spent 44µs making 1 call to warnings::import
51258µs236µs
# spent 29µs (23+6) within Mail::SpamAssassin::PerMsgLearner::BEGIN@51 which was called: # once (23µs+6µs) by main::BEGIN@68 at line 51
use bytes;
# spent 29µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@51 # spent 6µs making 1 call to bytes::import
52258µs2161µs
# spent 92µs (23+69) within Mail::SpamAssassin::PerMsgLearner::BEGIN@52 which was called: # once (23µs+69µs) by main::BEGIN@68 at line 52
use re 'taint';
# spent 92µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@52 # spent 69µs making 1 call to re::import
53
54251µs114µs
# spent 14µs within Mail::SpamAssassin::PerMsgLearner::BEGIN@54 which was called: # once (14µs+0s) by main::BEGIN@68 at line 54
use Mail::SpamAssassin;
# spent 14µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@54
55254µs117µs
# spent 17µs within Mail::SpamAssassin::PerMsgLearner::BEGIN@55 which was called: # once (17µs+0s) by main::BEGIN@68 at line 55
use Mail::SpamAssassin::PerMsgStatus;
# spent 17µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@55
562320µs12.16ms
# spent 2.16ms (1.66+507µs) within Mail::SpamAssassin::PerMsgLearner::BEGIN@56 which was called: # once (1.66ms+507µs) by main::BEGIN@68 at line 56
use Mail::SpamAssassin::Bayes;
# spent 2.16ms making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@56
57265µs2277µs
# spent 150µs (23+127) within Mail::SpamAssassin::PerMsgLearner::BEGIN@57 which was called: # once (23µs+127µs) by main::BEGIN@68 at line 57
use Mail::SpamAssassin::Logger;
# spent 150µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@57 # spent 127µs making 1 call to Exporter::import
58
5913µs
# spent 104µs (24+80) within Mail::SpamAssassin::PerMsgLearner::BEGIN@59 which was called: # once (24µs+80µs) by main::BEGIN@68 at line 61
use vars qw{
60 @ISA
611664µs2184µs};
# spent 104µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@59 # spent 80µs making 1 call to vars::import
62
6317µs@ISA = qw();
64
65###########################################################################
66
67
# spent 8.04ms within Mail::SpamAssassin::PerMsgLearner::new which was called 234 times, avg 34µs/call: # 234 times (8.04ms+0s) by Mail::SpamAssassin::learn at line 648 of Mail/SpamAssassin.pm, avg 34µs/call
sub new {
68234613µs my $class = shift;
69234688µs $class = ref($class) || $class;
70234547µ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
772342.13ms };
78
79234968µs $self->{conf} = $self->{main}->{conf};
80
81234900µs $self->{bayes_scanner} = $self->{main}->{bayes_scanner};
82
83234672µs bless ($self, $class);
842341.82ms $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 96432s (5.46ms+96432) within Mail::SpamAssassin::PerMsgLearner::learn_spam which was called 234 times, avg 412s/call: # 234 times (5.46ms+96432s) by Mail::SpamAssassin::learn at line 655 of Mail/SpamAssassin.pm, avg 412s/call
sub learn_spam {
101234497µ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.
11123411.5ms23496432s $self->{learned} = $self->{bayes_scanner}->learn (1, $self->{msg}, $id);
# spent 96432s making 234 calls to Mail::SpamAssassin::Bayes::learn, avg 412s/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
127sub 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
151sub 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
166Returns C<1> if the message was learned from or forgotten successfully.
167
168=cut
169
170
# spent 2.40ms within Mail::SpamAssassin::PerMsgLearner::did_learn which was called 234 times, avg 10µs/call: # 234 times (2.40ms+0s) by main::wanted at line 575 of /usr/local/bin/sa-learn, avg 10µs/call
sub did_learn {
171234703µs my ($self) = @_;
1722342.04ms return ($self->{learned});
173}
174
175###########################################################################
176
177=item $status->finish()
178
179Finish with the object.
180
181=cut
182
183
# spent 3.72ms within Mail::SpamAssassin::PerMsgLearner::finish which was called 234 times, avg 16µs/call: # 234 times (3.72ms+0s) by main::wanted at line 585 of /usr/local/bin/sa-learn, avg 16µs/call
sub finish {
184234514µs my $self = shift;
1854683.53ms %{$self} = ();
186}
187
188###########################################################################
189
19019µs1;
191__END__