← Index
NYTProf Performance Profile   « line view »
For /usr/local/bin/sa-learn
  Run on Tue Nov 7 05:38:10 2017
Reported on Tue Nov 7 06:16:03 2017

Filename/usr/local/lib/perl5/site_perl/Mail/SpamAssassin/PerMsgLearner.pm
StatementsExecuted 3545 statements in 28.3ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
235117.89ms7.89msMail::SpamAssassin::PerMsgLearner::::newMail::SpamAssassin::PerMsgLearner::new
235115.33ms1570sMail::SpamAssassin::PerMsgLearner::::learn_spamMail::SpamAssassin::PerMsgLearner::learn_spam
235113.49ms3.49msMail::SpamAssassin::PerMsgLearner::::finishMail::SpamAssassin::PerMsgLearner::finish
235112.25ms2.25msMail::SpamAssassin::PerMsgLearner::::did_learnMail::SpamAssassin::PerMsgLearner::did_learn
1111.79ms2.41msMail::SpamAssassin::PerMsgLearner::::BEGIN@56Mail::SpamAssassin::PerMsgLearner::BEGIN@56
11155µs92µsMail::SpamAssassin::PerMsgLearner::::BEGIN@50Mail::SpamAssassin::PerMsgLearner::BEGIN@50
11144µs54µsMail::SpamAssassin::PerMsgLearner::::BEGIN@49Mail::SpamAssassin::PerMsgLearner::BEGIN@49
11126µs212µsMail::SpamAssassin::PerMsgLearner::::BEGIN@57Mail::SpamAssassin::PerMsgLearner::BEGIN@57
11124µs99µsMail::SpamAssassin::PerMsgLearner::::BEGIN@59Mail::SpamAssassin::PerMsgLearner::BEGIN@59
11123µs30µsMail::SpamAssassin::PerMsgLearner::::BEGIN@51Mail::SpamAssassin::PerMsgLearner::BEGIN@51
11123µs81µsMail::SpamAssassin::PerMsgLearner::::BEGIN@52Mail::SpamAssassin::PerMsgLearner::BEGIN@52
11120µs20µsMail::SpamAssassin::PerMsgLearner::::BEGIN@54Mail::SpamAssassin::PerMsgLearner::BEGIN@54
11117µs17µsMail::SpamAssassin::PerMsgLearner::::BEGIN@55Mail::SpamAssassin::PerMsgLearner::BEGIN@55
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
492120µs264µ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
use strict;
# spent 54µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@49 # spent 10µs making 1 call to strict::import
50272µs2128µ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
use warnings;
# spent 92µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@50 # spent 36µs making 1 call to warnings::import
51270µs236µ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
use bytes;
# spent 30µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@51 # spent 6µs making 1 call to bytes::import
52271µs2140µ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
use re 'taint';
# spent 81µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@52 # spent 58µs making 1 call to re::import
53
54273µs120µs
# spent 20µs within Mail::SpamAssassin::PerMsgLearner::BEGIN@54 which was called: # once (20µs+0s) by main::BEGIN@68 at line 54
use Mail::SpamAssassin;
# spent 20µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@54
55261µ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
562306µs12.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
use Mail::SpamAssassin::Bayes;
# spent 2.41ms making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@56
57276µs2398µ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
use Mail::SpamAssassin::Logger;
# spent 212µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@57 # spent 186µs making 1 call to Exporter::import
58
5912µ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
use vars qw{
60 @ISA
611733µs2173µs};
# spent 99µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@59 # spent 75µs making 1 call to vars::import
62
6318µ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
sub new {
68235582µs my $class = shift;
69235639µs $class = ref($class) || $class;
70235519µ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
772352.13ms };
78
79235947µs $self->{conf} = $self->{main}->{conf};
80
81235938µs $self->{bayes_scanner} = $self->{main}->{bayes_scanner};
82
83235644µs bless ($self, $class);
842351.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
sub learn_spam {
101235510µ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.
11123511.6ms2351570s $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
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.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
sub did_learn {
171235653µs my ($self) = @_;
1722351.72ms return ($self->{learned});
173}
174
175###########################################################################
176
177=item $status->finish()
178
179Finish 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
sub finish {
184235513µs my $self = shift;
1854703.52ms %{$self} = ();
186}
187
188###########################################################################
189
190111µs1;
191__END__