← Index
NYTProf Performance Profile   « line view »
For /usr/local/bin/sa-learn
  Run on Sun Nov 5 02:36:06 2017
Reported on Sun Nov 5 02:56:20 2017

Filename/usr/local/lib/perl5/site_perl/Mail/SpamAssassin/PerMsgLearner.pm
StatementsExecuted 3530 statements in 21.5ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
234118.16ms8.16msMail::SpamAssassin::PerMsgLearner::::newMail::SpamAssassin::PerMsgLearner::new
234115.31ms710sMail::SpamAssassin::PerMsgLearner::::learn_spamMail::SpamAssassin::PerMsgLearner::learn_spam
234113.59ms3.59msMail::SpamAssassin::PerMsgLearner::::finishMail::SpamAssassin::PerMsgLearner::finish
234112.29ms2.29msMail::SpamAssassin::PerMsgLearner::::did_learnMail::SpamAssassin::PerMsgLearner::did_learn
1111.79ms2.44msMail::SpamAssassin::PerMsgLearner::::BEGIN@56Mail::SpamAssassin::PerMsgLearner::BEGIN@56
11151µs61µsMail::SpamAssassin::PerMsgLearner::::BEGIN@49Mail::SpamAssassin::PerMsgLearner::BEGIN@49
11138µs115µsMail::SpamAssassin::PerMsgLearner::::BEGIN@59Mail::SpamAssassin::PerMsgLearner::BEGIN@59
11138µs70µsMail::SpamAssassin::PerMsgLearner::::BEGIN@50Mail::SpamAssassin::PerMsgLearner::BEGIN@50
11127µs84µsMail::SpamAssassin::PerMsgLearner::::BEGIN@52Mail::SpamAssassin::PerMsgLearner::BEGIN@52
11126µs32µsMail::SpamAssassin::PerMsgLearner::::BEGIN@51Mail::SpamAssassin::PerMsgLearner::BEGIN@51
11125µs25µsMail::SpamAssassin::PerMsgLearner::::BEGIN@54Mail::SpamAssassin::PerMsgLearner::BEGIN@54
11122µs185µsMail::SpamAssassin::PerMsgLearner::::BEGIN@57Mail::SpamAssassin::PerMsgLearner::BEGIN@57
11120µs20µ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
492104µs270µ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
use strict;
# spent 61µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@49 # spent 10µs making 1 call to strict::import
50266µs2102µ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
use warnings;
# spent 70µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@50 # spent 32µs making 1 call to warnings::import
51269µs238µ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
use bytes;
# spent 32µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@51 # spent 6µs making 1 call to bytes::import
52261µs2140µ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
use re 'taint';
# spent 84µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@52 # spent 57µs making 1 call to re::import
53
54265µs125µs
# spent 25µs within Mail::SpamAssassin::PerMsgLearner::BEGIN@54 which was called: # once (25µs+0s) by main::BEGIN@68 at line 54
use Mail::SpamAssassin;
# spent 25µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@54
55259µs120µs
# spent 20µs within Mail::SpamAssassin::PerMsgLearner::BEGIN@55 which was called: # once (20µs+0s) by main::BEGIN@68 at line 55
use Mail::SpamAssassin::PerMsgStatus;
# spent 20µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@55
562313µs12.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
use Mail::SpamAssassin::Bayes;
# spent 2.44ms making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@56
57276µs2348µ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
use Mail::SpamAssassin::Logger;
# spent 185µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@57 # spent 163µs making 1 call to Exporter::import
58
5916µ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
use vars qw{
60 @ISA
611743µs2192µs};
# spent 115µs making 1 call to Mail::SpamAssassin::PerMsgLearner::BEGIN@59 # spent 77µs making 1 call to vars::import
62
63111µ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
sub new {
68234610µs my $class = shift;
69234650µs $class = ref($class) || $class;
70234556µ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.00ms };
78
792341.10ms $self->{conf} = $self->{main}->{conf};
80
812341.07ms $self->{bayes_scanner} = $self->{main}->{bayes_scanner};
82
83234659µs bless ($self, $class);
842341.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
sub learn_spam {
101234501µ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.
1112344.63ms234710s $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
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.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
sub did_learn {
171234650µs my ($self) = @_;
1722341.78ms return ($self->{learned});
173}
174
175###########################################################################
176
177=item $status->finish()
178
179Finish 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
sub finish {
184234502µs my $self = shift;
1854683.43ms %{$self} = ();
186}
187
188###########################################################################
189
190114µs1;
191__END__