Filename | /usr/local/lib/perl5/site_perl/Mail/SpamAssassin/Bayes.pm |
Statements | Executed 1201 statements in 9.32ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
234 | 1 | 1 | 7.45ms | 710s | learn | Mail::SpamAssassin::Bayes::
1 | 1 | 1 | 59µs | 66µs | BEGIN@35 | Mail::SpamAssassin::Bayes::
1 | 1 | 1 | 53µs | 30.5ms | new | Mail::SpamAssassin::Bayes::
1 | 1 | 1 | 35µs | 236µs | BEGIN@42 | Mail::SpamAssassin::Bayes::
1 | 1 | 1 | 32µs | 147µs | BEGIN@43 | Mail::SpamAssassin::Bayes::
1 | 1 | 1 | 31µs | 52µs | BEGIN@36 | Mail::SpamAssassin::Bayes::
1 | 1 | 1 | 30µs | 35µs | BEGIN@37 | Mail::SpamAssassin::Bayes::
1 | 1 | 1 | 28µs | 5.67s | force_close | Mail::SpamAssassin::Bayes::
1 | 1 | 1 | 27µs | 1.23ms | is_scan_available | Mail::SpamAssassin::Bayes::
1 | 1 | 1 | 24µs | 93µs | BEGIN@38 | Mail::SpamAssassin::Bayes::
1 | 1 | 1 | 13µs | 13µs | BEGIN@40 | Mail::SpamAssassin::Bayes::
1 | 1 | 1 | 10µs | 10µs | BEGIN@41 | Mail::SpamAssassin::Bayes::
0 | 0 | 0 | 0s | 0s | dump_bayes_db | Mail::SpamAssassin::Bayes::
0 | 0 | 0 | 0s | 0s | finish | Mail::SpamAssassin::Bayes::
0 | 0 | 0 | 0s | 0s | forget | Mail::SpamAssassin::Bayes::
0 | 0 | 0 | 0s | 0s | ignore_message | Mail::SpamAssassin::Bayes::
0 | 0 | 0 | 0s | 0s | sync | Mail::SpamAssassin::Bayes::
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::Bayes - support for learning classifiers | ||||
21 | |||||
22 | =head1 DESCRIPTION | ||||
23 | |||||
24 | This is the general class used to train a learning classifier with new samples | ||||
25 | of spam and ham mail, and classify based on prior training. | ||||
26 | |||||
27 | Prior to version 3.3.0, the default Bayes implementation was here; if you're | ||||
28 | looking for information on that, it has moved to | ||||
29 | C<Mail::SpamAssassin::Plugin::Bayes>. | ||||
30 | |||||
31 | =cut | ||||
32 | |||||
33 | package Mail::SpamAssassin::Bayes; | ||||
34 | |||||
35 | 2 | 57µs | 2 | 74µs | # spent 66µs (59+7) within Mail::SpamAssassin::Bayes::BEGIN@35 which was called:
# once (59µs+7µs) by Mail::SpamAssassin::PerMsgLearner::BEGIN@56 at line 35 # spent 66µs making 1 call to Mail::SpamAssassin::Bayes::BEGIN@35
# spent 7µs making 1 call to strict::import |
36 | 2 | 67µs | 2 | 74µs | # spent 52µs (31+21) within Mail::SpamAssassin::Bayes::BEGIN@36 which was called:
# once (31µs+21µs) by Mail::SpamAssassin::PerMsgLearner::BEGIN@56 at line 36 # spent 52µs making 1 call to Mail::SpamAssassin::Bayes::BEGIN@36
# spent 21µs making 1 call to warnings::import |
37 | 2 | 69µs | 2 | 39µs | # spent 35µs (30+5) within Mail::SpamAssassin::Bayes::BEGIN@37 which was called:
# once (30µs+5µs) by Mail::SpamAssassin::PerMsgLearner::BEGIN@56 at line 37 # spent 35µs making 1 call to Mail::SpamAssassin::Bayes::BEGIN@37
# spent 5µs making 1 call to bytes::import |
38 | 2 | 67µs | 2 | 162µs | # spent 93µs (24+69) within Mail::SpamAssassin::Bayes::BEGIN@38 which was called:
# once (24µs+69µs) by Mail::SpamAssassin::PerMsgLearner::BEGIN@56 at line 38 # spent 93µs making 1 call to Mail::SpamAssassin::Bayes::BEGIN@38
# spent 69µs making 1 call to re::import |
39 | |||||
40 | 2 | 58µs | 1 | 13µs | # spent 13µs within Mail::SpamAssassin::Bayes::BEGIN@40 which was called:
# once (13µs+0s) by Mail::SpamAssassin::PerMsgLearner::BEGIN@56 at line 40 # spent 13µs making 1 call to Mail::SpamAssassin::Bayes::BEGIN@40 |
41 | 2 | 61µs | 1 | 10µs | # spent 10µs within Mail::SpamAssassin::Bayes::BEGIN@41 which was called:
# once (10µs+0s) by Mail::SpamAssassin::PerMsgLearner::BEGIN@56 at line 41 # spent 10µs making 1 call to Mail::SpamAssassin::Bayes::BEGIN@41 |
42 | 2 | 73µs | 2 | 437µs | # spent 236µs (35+201) within Mail::SpamAssassin::Bayes::BEGIN@42 which was called:
# once (35µs+201µs) by Mail::SpamAssassin::PerMsgLearner::BEGIN@56 at line 42 # spent 236µs making 1 call to Mail::SpamAssassin::Bayes::BEGIN@42
# spent 201µs making 1 call to Exporter::import |
43 | 2 | 1.22ms | 2 | 262µs | # spent 147µs (32+115) within Mail::SpamAssassin::Bayes::BEGIN@43 which was called:
# once (32µs+115µs) by Mail::SpamAssassin::PerMsgLearner::BEGIN@56 at line 43 # spent 147µs making 1 call to Mail::SpamAssassin::Bayes::BEGIN@43
# spent 115µs making 1 call to Exporter::import |
44 | |||||
45 | 1 | 8µs | our @ISA = qw(); | ||
46 | |||||
47 | ########################################################################### | ||||
48 | |||||
49 | # spent 30.5ms (53µs+30.4) within Mail::SpamAssassin::Bayes::new which was called:
# once (53µs+30.4ms) by Mail::SpamAssassin::init at line 1773 of Mail/SpamAssassin.pm | ||||
50 | 1 | 3µs | my $class = shift; | ||
51 | 1 | 3µs | $class = ref($class) || $class; | ||
52 | |||||
53 | 1 | 2µs | my ($main) = @_; | ||
54 | my $self = { | ||||
55 | 'main' => $main, | ||||
56 | 'conf' => $main->{conf}, | ||||
57 | 1 | 7µs | 'use_ignores' => 1, | ||
58 | }; | ||||
59 | 1 | 3µs | bless ($self, $class); | ||
60 | |||||
61 | 1 | 20µs | 1 | 30.4ms | $self->{main}->call_plugins("learner_new"); # spent 30.4ms making 1 call to Mail::SpamAssassin::call_plugins |
62 | 1 | 13µs | $self; | ||
63 | } | ||||
64 | |||||
65 | ########################################################################### | ||||
66 | |||||
67 | sub finish { | ||||
68 | my $self = shift; | ||||
69 | # we don't need to do the plugin; Mail::SpamAssassin::finish() does | ||||
70 | # that for us | ||||
71 | %{$self} = (); | ||||
72 | } | ||||
73 | |||||
74 | ########################################################################### | ||||
75 | |||||
76 | # force the Bayes dbs to be closed, if they haven't already been; called | ||||
77 | # at the end of scan operation, or when switching between user IDs, | ||||
78 | # or when C<Mail::SpamAssassin::finish_learner()> is called. | ||||
79 | # | ||||
80 | # spent 5.67s (28µs+5.67) within Mail::SpamAssassin::Bayes::force_close which was called:
# once (28µs+5.67s) by Mail::SpamAssassin::finish_learner at line 758 of Mail/SpamAssassin.pm | ||||
81 | 1 | 2µs | my $self = shift; | ||
82 | 1 | 2µs | my $quiet = shift; | ||
83 | 1 | 24µs | 1 | 5.67s | $self->{main}->call_plugins("learner_close", { quiet => $quiet }); # spent 5.67s making 1 call to Mail::SpamAssassin::call_plugins |
84 | } | ||||
85 | |||||
86 | ########################################################################### | ||||
87 | |||||
88 | sub ignore_message { | ||||
89 | my ($self,$PMS) = @_; | ||||
90 | |||||
91 | return 0 unless $self->{use_ignores}; | ||||
92 | |||||
93 | my $ig_from = $self->{main}->call_plugins ("check_wb_list", | ||||
94 | { permsgstatus => $PMS, type => 'from', list => 'bayes_ignore_from' }); | ||||
95 | my $ig_to = $self->{main}->call_plugins ("check_wb_list", | ||||
96 | { permsgstatus => $PMS, type => 'to', list => 'bayes_ignore_to' }); | ||||
97 | |||||
98 | my $ignore = $ig_from || $ig_to; | ||||
99 | dbg("bayes: not using bayes, bayes_ignore_from or _to rule") if $ignore; | ||||
100 | return $ignore; | ||||
101 | } | ||||
102 | |||||
103 | ########################################################################### | ||||
104 | |||||
105 | # spent 710s (7.45ms+710) within Mail::SpamAssassin::Bayes::learn which was called 234 times, avg 3.03s/call:
# 234 times (7.45ms+710s) by Mail::SpamAssassin::PerMsgLearner::learn_spam at line 111 of Mail/SpamAssassin/PerMsgLearner.pm, avg 3.03s/call | ||||
106 | 234 | 563µs | my ($self, $isspam, $msg, $id) = @_; | ||
107 | 234 | 1.06ms | return unless $self->{conf}->{use_learner}; | ||
108 | 234 | 495µs | return unless defined $msg; | ||
109 | |||||
110 | 234 | 630µs | if( $self->{use_ignores} ) # Remove test when PerMsgStatus available. | ||
111 | { | ||||
112 | # DMK, koppel@ece.lsu.edu: Hoping that the ultimate fix to bug 2263 will | ||||
113 | # make it unnecessary to construct a PerMsgStatus here. | ||||
114 | my $PMS = new Mail::SpamAssassin::PerMsgStatus $self->{main}, $msg; | ||||
115 | my $ignore = $self->ignore_message($PMS); | ||||
116 | $PMS->finish(); | ||||
117 | return 0 if $ignore; | ||||
118 | } | ||||
119 | |||||
120 | 234 | 4.78ms | 234 | 710s | return $self->{main}->call_plugins("learn_message", { isspam => $isspam, msg => $msg, id => $id }); # spent 710s making 234 calls to Mail::SpamAssassin::call_plugins, avg 3.03s/call |
121 | } | ||||
122 | |||||
123 | ########################################################################### | ||||
124 | |||||
125 | sub forget { | ||||
126 | my ($self, $msg, $id) = @_; | ||||
127 | return unless $self->{conf}->{use_learner}; | ||||
128 | return unless defined $msg; | ||||
129 | return $self->{main}->call_plugins("forget_message", { msg => $msg, id => $id }); | ||||
130 | } | ||||
131 | |||||
132 | ########################################################################### | ||||
133 | |||||
134 | sub sync { | ||||
135 | my ($self, $sync, $expire, $opts) = @_; | ||||
136 | return 0 unless $self->{conf}->{use_learner}; | ||||
137 | |||||
138 | if ($sync) { | ||||
139 | $self->{main}->call_plugins("learner_sync", $opts ); | ||||
140 | } | ||||
141 | if ($expire) { | ||||
142 | $self->{main}->call_plugins("learner_expire_old_training", $opts ); | ||||
143 | } | ||||
144 | |||||
145 | return 0; | ||||
146 | } | ||||
147 | |||||
148 | ########################################################################### | ||||
149 | |||||
150 | # spent 1.23ms (27µs+1.20) within Mail::SpamAssassin::Bayes::is_scan_available which was called:
# once (27µs+1.20ms) by Mail::SpamAssassin::init at line 1780 of Mail/SpamAssassin.pm | ||||
151 | 1 | 2µs | my $self = shift; | ||
152 | 1 | 5µs | return 0 unless $self->{conf}->{use_learner}; | ||
153 | 1 | 16µs | 1 | 1.20ms | return $self->{main}->call_plugins("learner_is_scan_available"); # spent 1.20ms making 1 call to Mail::SpamAssassin::call_plugins |
154 | } | ||||
155 | |||||
156 | ########################################################################### | ||||
157 | |||||
158 | sub dump_bayes_db { | ||||
159 | my($self, $magic, $toks, $regex) = @_; | ||||
160 | return 0 unless $self->{conf}->{use_learner}; | ||||
161 | return $self->{main}->call_plugins("learner_dump_database", { | ||||
162 | magic => $magic, toks => $toks, regex => $regex }); | ||||
163 | } | ||||
164 | |||||
165 | 1 | 12µs | 1; |